summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorzhengbin <zhengbin13@huawei.com>2019-07-23 22:10:42 +0800
committerJens Axboe <axboe@kernel.dk>2019-08-12 08:15:36 -0600
commit73d9c8d4c0017e21e1ff519474ceb1450484dc9a (patch)
tree1d557ba1de029f9cb5025e204bd805beea4f0962 /block
parent52f6f9d74f31078964ca1574f7bb612da7877ac8 (diff)
blk-mq: Fix memory leak in blk_mq_init_allocated_queue error handling
If blk_mq_init_allocated_queue->elevator_init_mq fails, need to release the previously requested resources. Fixes: d34849913819 ("blk-mq-sched: allow setting of default IO scheduler") Signed-off-by: zhengbin <zhengbin13@huawei.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-mq.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 6968de9d7402..509f69fdfcf2 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2846,6 +2846,8 @@ static unsigned int nr_hw_queues(struct blk_mq_tag_set *set)
struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
struct request_queue *q)
{
+ int ret = -ENOMEM;
+
/* mark the queue as mq asap */
q->mq_ops = set->ops;
@@ -2907,17 +2909,18 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
blk_mq_map_swqueue(q);
if (!(set->flags & BLK_MQ_F_NO_SCHED)) {
- int ret;
-
ret = elevator_init_mq(q);
if (ret)
- return ERR_PTR(ret);
+ goto err_tag_set;
}
return q;
+err_tag_set:
+ blk_mq_del_queue_tag_set(q);
err_hctxs:
kfree(q->queue_hw_ctx);
+ q->nr_hw_queues = 0;
err_sys_init:
blk_mq_sysfs_deinit(q);
err_poll: