If queue mapping is set for polling while mq_ops->poll() not defined, blk_poll() will crash directly. I can understand this constraint is achieved by ensuring that mq_ops->poll() will always be defined whenever queue mapping is set for polling during code review phase. However adding the extra checking can enhance the code robustness, and the checking is cheap after all since it's done only once when initializing the queue. Signed-off-by: Jeffle Xu <jefflexu@xxxxxxxxxxxxxxxxx> --- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index b3d2785eefe9..12f6b3406211 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3204,7 +3204,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->tag_set = set; q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT; - if (set->nr_maps > HCTX_TYPE_POLL && + if (q->mq_ops->poll && set->nr_maps > HCTX_TYPE_POLL && set->map[HCTX_TYPE_POLL].nr_queues) blk_queue_flag_set(QUEUE_FLAG_POLL, q); -- 2.27.0