Skip to contentSkip to conversation

blk-mq error handling memory leak

PATCH Applied Jes Sorensen 2 participants 4 messages Apr 19, 2019 – May 29, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

cover blk-mq error handling memory leak

From: Jes Sorensen <[email protected]>

Hi,

Digging through this, I don't see the callback data getting freed in case of errors in blk_mq_init_allocated_queue() unless I am missing some obscure path that cleans it up later?

Cheers,
Jes

Jes Sorensen (1):
blk-mq: Fix memory leak in error handling

 block/blk-mq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
#1 lore raw

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

From: Jes Sorensen <[email protected]>

If blk_mq_init_allocated_queue() fails, make sure to free the poll stat callback struct allocated.

---
 block/blk-mq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
block/blk-mq.c +4 -1
index 9516304a38ee..7aa90c0b056b 100644
@@ -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);
Signature · 1 line
2.17.1
maintainer Applied
#2 lore raw

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

Quoted 4 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

If blk_mq_init_allocated_queue() fails, make sure to free the poll stat callback struct allocated.

Applied, thanks.

Signature · 1 line
Jens Axboe
#3 lore raw
In reply to Jes Sorensen
Quoted 7 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

Hi,

Digging through this, I don't see the callback data getting freed in case of errors in blk_mq_init_allocated_queue() unless I am missing some obscure path that cleans it up later?

Ping!

Any reason not to apply this?

Thanks,
Jes

Quoted 9 lines

Cheers,
Jes

Jes Sorensen (1):
blk-mq: Fix memory leak in error handling

 block/blk-mq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)