diff mbox

[01/14] blk-mq: Fix memory leaks on queue cleanup

Message ID 6bbad3e6321685525574d6c0f01b875375351b81.1474183901.git.agordeev@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Gordeev Sept. 18, 2016, 7:37 a.m. UTC
Some data are leaked when blk_cleanup_queue() interface
is called.

CC: linux-block@vger.kernel.org
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 block/blk-mq.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Sept. 19, 2016, 1:51 p.m. UTC | #1
On Sun, Sep 18, 2016 at 09:37:11AM +0200, Alexander Gordeev wrote:
> Some data are leaked when blk_cleanup_queue() interface
> is called.

I don't think this is correct - we free them in blk_mq_release.
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index f1c5263..66505af7 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1699,8 +1699,13 @@  static void blk_mq_free_hw_queues(struct request_queue *q,
 	struct blk_mq_hw_ctx *hctx;
 	unsigned int i;
 
-	queue_for_each_hw_ctx(q, hctx, i)
+	queue_for_each_hw_ctx(q, hctx, i) {
 		free_cpumask_var(hctx->cpumask);
+		kfree(hctx->ctxs);
+		kfree(hctx);
+	}
+
+	q->nr_hw_queues = 0;
 }
 
 static int blk_mq_init_hctx(struct request_queue *q,