From 74170118b26e55b611de5210f47657118a03a0e1 Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Thu, 29 Jan 2015 20:17:26 +0800 Subject: Revert "blk-mq: fix hctx/ctx kobject use-after-free" This reverts commit 76d697d10769048e5721510100bf3a9413a56385. The commit 76d697d10769048 causes general protection fault reported from Bart Van Assche: https://lkml.org/lkml/2015/1/28/334 Reported-by: Bart Van Assche Signed-off-by: Ming Lei Signed-off-by: Jens Axboe --- block/blk-mq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'block/blk-mq.c') diff --git a/block/blk-mq.c b/block/blk-mq.c index 9ee3b87c4498..2f95747c287e 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1641,8 +1641,10 @@ 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); + } } static int blk_mq_init_hctx(struct request_queue *q, @@ -2000,9 +2002,11 @@ void blk_mq_free_queue(struct request_queue *q) percpu_ref_exit(&q->mq_usage_counter); + free_percpu(q->queue_ctx); kfree(q->queue_hw_ctx); kfree(q->mq_map); + q->queue_ctx = NULL; q->queue_hw_ctx = NULL; q->mq_map = NULL; -- cgit v1.2.3