summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2019-02-19 06:08:19 +0300
committerJens Axboe <axboe@kernel.dk>2019-02-19 19:19:06 +0300
commit49b1f22b567ba1d7d8174950be4398a69d0effb7 (patch)
tree52811398366d5cc858edaebe17ca7cb1238a9777 /block
parent6fb845f0e78de19eaaf6a2d351702474e44b6a9e (diff)
downloadlinux-49b1f22b567ba1d7d8174950be4398a69d0effb7.tar.xz
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.c4
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,
struct bio_vec bv, bvprv = { NULL };
int prev = 0;
unsigned int seg_size, nr_phys_segs;
- unsigned front_seg_size = bio->bi_seg_front_size;
+ unsigned front_seg_size;
struct bio *fbio, *bbio;
struct bvec_iter iter;
if (!bio)
return 0;
+ front_seg_size = bio->bi_seg_front_size;
+
switch (bio_op(bio)) {
case REQ_OP_DISCARD:
case REQ_OP_SECURE_ERASE: