summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorJes Sorensen <jsorensen@fb.com>2019-04-19 22:35:44 +0200
committerJens Axboe <axboe@kernel.dk>2019-05-29 22:33:04 +0200
commit41de54c64811bf087c8464fdeb43c6ad8be2686b (patch)
treea489bff9589f120fe7bf570168ce014d76f034e9 /block
parentblock: don't protect generic_make_request_checks with blk_queue_enter (diff)
downloadlinux-41de54c64811bf087c8464fdeb43c6ad8be2686b.tar.xz
linux-41de54c64811bf087c8464fdeb43c6ad8be2686b.zip
blk-mq: Fix memory leak in error handling
If blk_mq_init_allocated_queue() fails, make sure to free the poll stat callback struct allocated. Signed-off-by: Jes Sorensen <jsorensen@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-mq.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 32b8ad3d341b..ce0f5f4ede70 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2865,7 +2865,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
goto err_exit;
if (blk_mq_alloc_ctxs(q))
- goto err_exit;
+ goto err_poll;
/* init q->mq_kobj and sw queues' kobjects */
blk_mq_sysfs_init(q);
@@ -2929,6 +2929,9 @@ err_hctxs:
kfree(q->queue_hw_ctx);
err_sys_init:
blk_mq_sysfs_deinit(q);
+err_poll:
+ blk_stat_free_callback(q->poll_cb);
+ q->poll_cb = NULL;
err_exit:
q->mq_ops = NULL;
return ERR_PTR(-ENOMEM);