diff options
author | Ming Lei <ming.lei@redhat.com> | 2019-02-18 22:08:19 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-02-19 11:19:06 -0500 |
commit | 49b1f22b567ba1d7d8174950be4398a69d0effb7 (patch) | |
tree | 52811398366d5cc858edaebe17ca7cb1238a9777 /block | |
parent | 6fb845f0e78de19eaaf6a2d351702474e44b6a9e (diff) |
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 <bvanassche@acm.org>
Reported-by: Bart Van Assche <bvanassche@acm.org>
Fixes: dcebd755926b0f39dd1e ("block: use bio_for_each_bvec() to compute multi-page bvec count")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-merge.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c index bed065904677..066b66430523 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -363,13 +363,15 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, | |||
363 | struct bio_vec bv, bvprv = { NULL }; | 363 | struct bio_vec bv, bvprv = { NULL }; |
364 | int prev = 0; | 364 | int prev = 0; |
365 | unsigned int seg_size, nr_phys_segs; | 365 | unsigned int seg_size, nr_phys_segs; |
366 | unsigned front_seg_size = bio->bi_seg_front_size; | 366 | unsigned front_seg_size; |
367 | struct bio *fbio, *bbio; | 367 | struct bio *fbio, *bbio; |
368 | struct bvec_iter iter; | 368 | struct bvec_iter iter; |
369 | 369 | ||
370 | if (!bio) | 370 | if (!bio) |
371 | return 0; | 371 | return 0; |
372 | 372 | ||
373 | front_seg_size = bio->bi_seg_front_size; | ||
374 | |||
373 | switch (bio_op(bio)) { | 375 | switch (bio_op(bio)) { |
374 | case REQ_OP_DISCARD: | 376 | case REQ_OP_DISCARD: |
375 | case REQ_OP_SECURE_ERASE: | 377 | case REQ_OP_SECURE_ERASE: |