Patch "block: Fix page refcounts for unaligned buffers in __bio_release_pages()" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    block: Fix page refcounts for unaligned buffers in __bio_release_pages()

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     block-fix-page-refcounts-for-unaligned-buffers-in-__.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 894fe962dd4294fc9dc0d4f0e5343a5c944885e2
Author: Tony Battersby <tonyb@xxxxxxxxxxxxxxx>
Date:   Thu Feb 29 13:08:09 2024 -0500

    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@xxxxxxxxxxxxxxx
    Signed-off-by: Tony Battersby <tonyb@xxxxxxxxxxxxxxx>
    Tested-by: Greg Edwards <gedwards@xxxxxxx>
    Link: https://lore.kernel.org/r/86e592a9-98d4-4cff-a646-0c0084328356@xxxxxxxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/bio.c b/block/bio.c
index b9642a41f286e..b52b56067e792 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1152,7 +1152,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);
@@ -1160,10 +1160,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);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux