diff mbox series

[1/1] blk-mq: Fix memory leak in error handling

Message ID 20190419203544.11725-2-Jes.Sorensen@gmail.com (mailing list archive)
State New, archived
Headers show
Series blk-mq error handling memory leak | expand

Commit Message

Jes Sorensen April 19, 2019, 8:35 p.m. UTC
From: Jes Sorensen <jsorensen@fb.com>

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>
---
 block/blk-mq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jens Axboe May 29, 2019, 8:33 p.m. UTC | #1
On 4/19/19 2:35 PM, Jes Sorensen wrote:
> From: Jes Sorensen <jsorensen@fb.com>
> 
> If blk_mq_init_allocated_queue() fails, make sure to free the poll
> stat callback struct allocated.

Applied, thanks.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 9516304a38ee..7aa90c0b056b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2838,7 +2838,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);
@@ -2899,6 +2899,9 @@  struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
 	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);