From: Jes Sorensen Date: Fri, 19 Apr 2019 20:35:44 +0000 (-0400) Subject: blk-mq: Fix memory leak in error handling X-Git-Tag: v5.4-rc1~579^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=41de54c64811bf087c8464fdeb43c6ad8be2686b;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Jens Axboe --- diff --git a/block/blk-mq.c b/block/blk-mq.c index 32b8ad3..ce0f5f4 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);