]> Gentwo Git Trees - linux/.git/commitdiff
block: fix merging data-less bios
authorKeith Busch <kbusch@kernel.org>
Tue, 11 Nov 2025 14:06:20 +0000 (06:06 -0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 11 Nov 2025 15:35:59 +0000 (08:35 -0700)
The data segment gaps the block layer tracks doesn't apply to bio's that
don't have data. Skip calculating this to fix a NULL pointer access.

Fixes: 2f6b2565d43cdb5 ("block: accumulate memory segment gaps per bio")
Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Yu Kuai <yukuai@fnnas.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-merge.c

index 3ca6fbf8b7870ff96f1b00a352280e00e37a0f71..d3115d7469df07f7b36b3cc9b0a7e494ce2e6150 100644 (file)
@@ -737,6 +737,9 @@ u8 bio_seg_gap(struct request_queue *q, struct bio *prev, struct bio *next,
 {
        struct bio_vec pb, nb;
 
+       if (!bio_has_data(prev))
+               return 0;
+
        gaps_bit = min_not_zero(gaps_bit, prev->bi_bvec_gap_bit);
        gaps_bit = min_not_zero(gaps_bit, next->bi_bvec_gap_bit);