Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

blk-mq: fix potential oops with polling and blk-mq scheduler

If we have a scheduler attached, blk_mq_tag_to_rq() on the
scheduled tags will return NULL if a request is no longer
in flight. This is different than using the normal tags,
where it will always return the fixed request. Check for
this condition for polling, in case we happen to enter
polling for a completed request.

The request address remains valid, so this check and return
should be perfectly safe.

Fixes: bd166ef183c2 ("blk-mq-sched: add framework for MQ capable IO schedulers")
Tested-by: Stephen Bates <sbates@raithlin.com>
Signed-off-by: Jens Axboe <axboe@fb.com>

+10 -1
+10 -1
block/blk-mq.c
··· 2928 2928 hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)]; 2929 2929 if (!blk_qc_t_is_internal(cookie)) 2930 2930 rq = blk_mq_tag_to_rq(hctx->tags, blk_qc_t_to_tag(cookie)); 2931 - else 2931 + else { 2932 2932 rq = blk_mq_tag_to_rq(hctx->sched_tags, blk_qc_t_to_tag(cookie)); 2933 + /* 2934 + * With scheduling, if the request has completed, we'll 2935 + * get a NULL return here, as we clear the sched tag when 2936 + * that happens. The request still remains valid, like always, 2937 + * so we should be safe with just the NULL check. 2938 + */ 2939 + if (!rq) 2940 + return false; 2941 + } 2933 2942 2934 2943 return __blk_mq_poll(hctx, rq); 2935 2944 }