From: Keith Busch <kbusch@meta.com>
To: <linux-block@vger.kernel.org>, <axboe@kernel.dk>, <hch@lst.de>
Cc: <yukuai@fnnas.com>, Keith Busch <kbusch@kernel.org>,
Matthew Wilcox <willy@infradead.org>
Subject: [PATCH] block: fix merging data-less bios
Date: Tue, 11 Nov 2025 06:06:20 -0800 [thread overview]
Message-ID: <20251111140620.2606536-1-kbusch@meta.com> (raw)
From: Keith Busch <kbusch@kernel.org>
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>
---
block/blk-merge.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 3ca6fbf8b7870..d3115d7469df0 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -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);
--
2.47.3
next reply other threads:[~2025-11-11 14:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 14:06 Keith Busch [this message]
2025-11-11 14:10 ` [PATCH] block: fix merging data-less bios Christoph Hellwig
2025-11-11 14:18 ` Yu Kuai
2025-11-11 15:36 ` Jens Axboe
2025-11-11 15:45 ` Matthew Wilcox
2025-11-11 16:00 ` Chaitanya Kulkarni
2025-11-11 16:26 ` Venkat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251111140620.2606536-1-kbusch@meta.com \
--to=kbusch@meta.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=willy@infradead.org \
--cc=yukuai@fnnas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox