summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorzhengbin <zhengbin13@huawei.com>2019-08-12 15:36:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-01 09:26:10 +0300
commit40cdc71e11113d5cf0ec11f447e293828e6f4217 (patch)
tree7886c2b1196807f4a1dd09d01d11b8ece3e8b7e2 /block
parent313efb253d03d7b5dc3dee1d25098133fc8b12a5 (diff)
downloadlinux-40cdc71e11113d5cf0ec11f447e293828e6f4217.tar.xz
blk-mq: move cancel of requeue_work to the front of blk_exit_queue
[ Upstream commit e26cc08265dda37d2acc8394604f220ef412299d ] blk_exit_queue will free elevator_data, while blk_mq_requeue_work will access it. Move cancel of requeue_work to the front of blk_exit_queue to avoid use-after-free. blk_exit_queue blk_mq_requeue_work __elevator_exit blk_mq_run_hw_queues blk_mq_exit_sched blk_mq_run_hw_queue dd_exit_queue blk_mq_hctx_has_pending kfree(elevator_data) blk_mq_sched_has_work dd_has_work Fixes: fbc2a15e3433 ("blk-mq: move cancel of requeue_work into blk_mq_release") Cc: stable@vger.kernel.org Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: zhengbin <zhengbin13@huawei.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block')
-rw-r--r--block/blk-mq.c2
-rw-r--r--block/blk-sysfs.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 9dfafee65bce..7ea85ec52026 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2461,8 +2461,6 @@ void blk_mq_release(struct request_queue *q)
struct blk_mq_hw_ctx *hctx;
unsigned int i;
- cancel_delayed_work_sync(&q->requeue_work);
-
/* hctx kobj stays in hctx */
queue_for_each_hw_ctx(q, hctx, i) {
if (!hctx)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 3772671cf2bc..bab47a17b96f 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -836,6 +836,9 @@ static void __blk_release_queue(struct work_struct *work)
blk_free_queue_stats(q->stats);
+ if (q->mq_ops)
+ cancel_delayed_work_sync(&q->requeue_work);
+
blk_exit_rl(q, &q->root_rl);
if (q->queue_tags)