提交 1e41c505 编写于 作者: J Joseph Qi 提交者: Shile Zhang

blk-mq: fix NULL pointer deference in case no poll implementation

In case some drivers such virtio-blk, poll function is not implementatin
yet. Before commit 529262d5 ("block: remove ->poll_fn"), q->poll_fn
is NULL and then blk_poll() won't do poll actually.
So add a check for this to avoid NULL pointer dereference when calling
q->mq_ops->poll.
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 fce831f9
......@@ -3283,7 +3283,7 @@ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin)
struct blk_mq_hw_ctx *hctx;
long state;
if (!blk_qc_t_valid(cookie) ||
if (!blk_qc_t_valid(cookie) || !q->mq_ops->poll ||
!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册