[PATCH] block: check poll() callback when setting QUEUE_FLAG_POLL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux