Skip to content

Commit e26cc08

Browse files
zhengbin13axboe
authored andcommitted
blk-mq: move cancel of requeue_work to the front of blk_exit_queue
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: fbc2a15 ("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>
1 parent 0c9c830 commit e26cc08

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎block/blk-mq.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,8 +2666,6 @@ void blk_mq_release(struct request_queue *q)
26662666
struct blk_mq_hw_ctx *hctx, *next;
26672667
int i;
26682668

2669-
cancel_delayed_work_sync(&q->requeue_work);
2670-
26712669
queue_for_each_hw_ctx(q, hctx, i)
26722670
WARN_ON_ONCE(hctx && list_empty(&hctx->hctx_list));
26732671

‎block/blk-sysfs.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,9 @@ static void __blk_release_queue(struct work_struct *work)
892892

893893
blk_free_queue_stats(q->stats);
894894

895+
if (queue_is_mq(q))
896+
cancel_delayed_work_sync(&q->requeue_work);
897+
895898
blk_exit_queue(q);
896899

897900
blk_queue_free_zone_bitmaps(q);

0 commit comments

Comments
 (0)