deadline_##name##_next_rq_show() walks per_prio->sort_list[data_dir] via deadline_from_pos() and prints the request that it finds without holding dd->lock. Concurrent request insertion and dispatching modify that RB-tree, so the traversal may follow stale pointers. Additionally, the request may be dispatched, completed and reused for another I/O while __blk_mq_debugfs_rq_show() prints it. Fix this by holding dd->lock while looking up and printing the request, as the other mq-deadline debugfs functions that iterate over requests already do. Fixes: daaadb3e9453 ("mq-deadline: add debugfs attributes") Cc: stable@vger.kernel.org Signed-off-by: Bart Van Assche --- block/mq-deadline.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index e5db1ee097c3..2bc70a5657cb 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -843,10 +843,12 @@ static int deadline_##name##_next_rq_show(void *data, \ struct dd_per_prio *per_prio = &dd->per_prio[prio]; \ struct request *rq; \ \ + spin_lock(&dd->lock); \ rq = deadline_from_pos(per_prio, data_dir, \ per_prio->latest_pos[data_dir]); \ if (rq) \ __blk_mq_debugfs_rq_show(m, rq); \ + spin_unlock(&dd->lock); \ return 0; \ }