Skip to contentSkip to conversation

block: fix merging data-less bios

PATCH Applied Keith Busch 7 participants 7 messages Nov 11, 2025 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix merging data-less bios

From: Keith Busch <[email protected]>

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")
---
 block/blk-merge.c | 3 +++
 1 file changed, 3 insertions(+)
block/blk-merge.c +3 -0
index 3ca6fbf8b7870..d3115d7469df0 100644
@@ -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);
 
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Keith Busch

From: Keith Busch <[email protected]>

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")

Looks good:

Reviewed-by on v1 1/1
#2 lore raw
In reply to Keith Busch
Quoted 9 lines · Keith Busch

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")
---
  block/blk-merge.c | 3 +++
  1 file changed, 3 insertions(+)

LGTM

maintainer Applied
#3 lore raw
In reply to Keith Busch
Quoted 4 lines · Keith Busch

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.

Applied, thanks!

[1/1] block: fix merging data-less bios

      commit: fd9ecd005252b595fd02ff7fcc4056251027404d

Best regards,

Signature · 1 line
Jens Axboe
Tested-by on v1 1/1
#4 lore raw
In reply to Keith Busch
Quoted 8 lines · Keith Busch

From: Keith Busch <[email protected]>

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")

Thanks for the quick fix!

Reviewed-by on v1 1/1
#5 lore raw
In reply to Keith Busch
Quoted 9 lines · Keith Busch

From: Keith Busch<[email protected]>

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")

---

Looks good.

-ck

Tested-by on v1 1/1
#6 lore raw
In reply to Keith Busch
Quoted 13 lines · Keith Busch

From: Keith Busch <[email protected]>

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")

---

Thanks for pointing to this fix. Tested this on IBM Power9 server and it fixes reported issue.

Please add below tag.

Regards,
Venkat.

Quoted 20 lines

block/blk-merge.c | 3 +++

1 file changed, 3 insertions(+)
block/blk-merge.c +3 -0
index 3ca6fbf8b7870..d3115d7469df0 100644
@@ -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);
 
Signature · 1 line
2.47.3