summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorTony Battersby <tonyb@cybernetics.com>2024-02-29 13:08:09 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-04-03 15:28:27 +0200
commit7d3765550374f71248c55e6206ea1d6fd4537e65 (patch)
tree3cfbfbeb6f67b7d7d0a2f390c7266c44c843bea1 /block
parent653d51504f41efb9f44744ec75e6b425a79714f3 (diff)
downloadlinux-rpi-7d3765550374f71248c55e6206ea1d6fd4537e65.tar.gz
linux-rpi-7d3765550374f71248c55e6206ea1d6fd4537e65.tar.bz2
linux-rpi-7d3765550374f71248c55e6206ea1d6fd4537e65.zip
block: Fix page refcounts for unaligned buffers in __bio_release_pages()
[ Upstream commit 38b43539d64b2fa020b3b9a752a986769f87f7a6 ] Fix an incorrect number of pages being released for buffers that do not start at the beginning of a page. Fixes: 1b151e2435fc ("block: Remove special-casing of compound pages") Cc: stable@vger.kernel.org Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Tested-by: Greg Edwards <gedwards@ddn.com> Link: https://lore.kernel.org/r/86e592a9-98d4-4cff-a646-0c0084328356@cybernetics.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block')
-rw-r--r--block/bio.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/block/bio.c b/block/bio.c
index 270f6b99926e..62419aa09d73 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1149,7 +1149,7 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty)
bio_for_each_folio_all(fi, bio) {
struct page *page;
- size_t done = 0;
+ size_t nr_pages;
if (mark_dirty) {
folio_lock(fi.folio);
@@ -1157,10 +1157,11 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty)
folio_unlock(fi.folio);
}
page = folio_page(fi.folio, fi.offset / PAGE_SIZE);
+ nr_pages = (fi.offset + fi.length - 1) / PAGE_SIZE -
+ fi.offset / PAGE_SIZE + 1;
do {
bio_release_page(bio, page++);
- done += PAGE_SIZE;
- } while (done < fi.length);
+ } while (--nr_pages != 0);
}
}
EXPORT_SYMBOL_GPL(__bio_release_pages);