2019-05-24 06:17:36

by Peng Wang

[permalink] [raw]
Subject: [UNTESTED PATCH] block: fix a potential null pointer dereference

blk_queue_dying() still needs request_queue "q" when
enter_succeeded is false, so let's set "q" zero later.

Signed-off-by: Peng Wang <[email protected]>
---
block/blk-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 419d600e6637..3d43909db3b8 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1056,7 +1056,6 @@ blk_qc_t generic_make_request(struct bio *bio)
flags = BLK_MQ_REQ_NOWAIT;
if (blk_queue_enter(q, flags) < 0) {
enter_succeeded = false;
- q = NULL;
}
}

@@ -1088,6 +1087,7 @@ blk_qc_t generic_make_request(struct bio *bio)
bio_wouldblock_error(bio);
else
bio_io_error(bio);
+ q = NULL;
}
bio = bio_list_pop(&bio_list_on_stack[0]);
} while (bio);
--
2.19.1