Commit bc188d81 authored by Sam Bradshaw's avatar Sam Bradshaw Committed by Jens Axboe

blkmq: Fix NULL pointer deref when all reserved tags in

When allocating from the reserved tags pool, bt_get() is called with
a NULL hctx.  If all tags are in use, the hw queue is kicked to push
out any pending IO, potentially freeing tags, and tag allocation is
retried.  The problem is that blk_mq_run_hw_queue() doesn't check for
a NULL hctx.  So we avoid it with a simple NULL hctx test.

Tested by hammering mtip32xx with concurrent smartctl/hdparm.
Signed-off-by: default avatarSam Bradshaw <sbradshaw@micron.com>
Signed-off-by: default avatarSelvan Mani <smani@micron.com>
Fixes: b3223207 ("blk-mq: fix hang in bt_get()")
Cc: stable@kernel.org

Added appropriate comment.
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 9a30b096
...@@ -278,8 +278,10 @@ static int bt_get(struct blk_mq_alloc_data *data, ...@@ -278,8 +278,10 @@ static int bt_get(struct blk_mq_alloc_data *data,
/* /*
* We're out of tags on this hardware queue, kick any * We're out of tags on this hardware queue, kick any
* pending IO submits before going to sleep waiting for * pending IO submits before going to sleep waiting for
* some to complete. * some to complete. Note that hctx can be NULL here for
* reserved tag allocation.
*/ */
if (hctx)
blk_mq_run_hw_queue(hctx, false); blk_mq_run_hw_queue(hctx, false);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment