Skip to content

Commit 49b1f22

Browse files
Ming Leiaxboe
authored andcommitted
block: avoid to READ fields of null bio
rq->bio can be NULL sometimes, such as flush request, so don't read bio->bi_seg_front_size until this 'bio' is checked as valid. Cc: Bart Van Assche <[email protected]> Reported-by: Bart Van Assche <[email protected]> Fixes: dcebd75 ("block: use bio_for_each_bvec() to compute multi-page bvec count") Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 6fb845f commit 49b1f22

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

block/blk-merge.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,15 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
363363
struct bio_vec bv, bvprv = { NULL };
364364
int prev = 0;
365365
unsigned int seg_size, nr_phys_segs;
366-
unsigned front_seg_size = bio->bi_seg_front_size;
366+
unsigned front_seg_size;
367367
struct bio *fbio, *bbio;
368368
struct bvec_iter iter;
369369

370370
if (!bio)
371371
return 0;
372372

373+
front_seg_size = bio->bi_seg_front_size;
374+
373375
switch (bio_op(bio)) {
374376
case REQ_OP_DISCARD:
375377
case REQ_OP_SECURE_ERASE:

0 commit comments

Comments
 (0)