Commit 4c17461b authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

blk-mq: Fix memory leak in error handling

[ Upstream commit 41de54c6 ]

If blk_mq_init_allocated_queue() fails, make sure to free the poll
stat callback struct allocated.
Signed-off-by: default avatarJes Sorensen <jsorensen@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent a6c6ea45
...@@ -2846,7 +2846,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, ...@@ -2846,7 +2846,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
goto err_exit; goto err_exit;
if (blk_mq_alloc_ctxs(q)) if (blk_mq_alloc_ctxs(q))
goto err_exit; goto err_poll;
/* init q->mq_kobj and sw queues' kobjects */ /* init q->mq_kobj and sw queues' kobjects */
blk_mq_sysfs_init(q); blk_mq_sysfs_init(q);
...@@ -2907,6 +2907,9 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, ...@@ -2907,6 +2907,9 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
kfree(q->queue_hw_ctx); kfree(q->queue_hw_ctx);
err_sys_init: err_sys_init:
blk_mq_sysfs_deinit(q); blk_mq_sysfs_deinit(q);
err_poll:
blk_stat_free_callback(q->poll_cb);
q->poll_cb = NULL;
err_exit: err_exit:
q->mq_ops = NULL; q->mq_ops = NULL;
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
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