linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] blk-mq error handling memory leak
@ 2019-04-19 20:35 Jes Sorensen
  2019-04-19 20:35 ` [PATCH 1/1] blk-mq: Fix memory leak in error handling Jes Sorensen
  2019-05-29 20:16 ` [PATCH 0/1] blk-mq error handling memory leak Jes Sorensen
  0 siblings, 2 replies; 4+ messages in thread
From: Jes Sorensen @ 2019-04-19 20:35 UTC (permalink / raw)
  To: linux-block; +Cc: kernel-team, Jes Sorensen

From: Jes Sorensen <jsorensen@fb.com>

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(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] blk-mq: Fix memory leak in error handling
  2019-04-19 20:35 [PATCH 0/1] blk-mq error handling memory leak Jes Sorensen
@ 2019-04-19 20:35 ` Jes Sorensen
  2019-05-29 20:33   ` Jens Axboe
  2019-05-29 20:16 ` [PATCH 0/1] blk-mq error handling memory leak Jes Sorensen
  1 sibling, 1 reply; 4+ messages in thread
From: Jes Sorensen @ 2019-04-19 20:35 UTC (permalink / raw)
  To: linux-block; +Cc: kernel-team, Jes Sorensen

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(-)

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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/1] blk-mq error handling memory leak
  2019-04-19 20:35 [PATCH 0/1] blk-mq error handling memory leak Jes Sorensen
  2019-04-19 20:35 ` [PATCH 1/1] blk-mq: Fix memory leak in error handling Jes Sorensen
@ 2019-05-29 20:16 ` Jes Sorensen
  1 sibling, 0 replies; 4+ messages in thread
From: Jes Sorensen @ 2019-05-29 20:16 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Kernel Team

On 4/19/19 4:35 PM, Jes Sorensen wrote:
> From: Jes Sorensen <jsorensen@fb.com>
> 
> 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

> 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(-)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] blk-mq: Fix memory leak in error handling
  2019-04-19 20:35 ` [PATCH 1/1] blk-mq: Fix memory leak in error handling Jes Sorensen
@ 2019-05-29 20:33   ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-05-29 20:33 UTC (permalink / raw)
  To: Jes Sorensen, linux-block; +Cc: kernel-team, Jes Sorensen

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.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-29 20:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-19 20:35 [PATCH 0/1] blk-mq error handling memory leak Jes Sorensen
2019-04-19 20:35 ` [PATCH 1/1] blk-mq: Fix memory leak in error handling Jes Sorensen
2019-05-29 20:33   ` Jens Axboe
2019-05-29 20:16 ` [PATCH 0/1] blk-mq error handling memory leak Jes Sorensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).