[PATCH] blk-mq: fix possible NULL pointer access in classic polling

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

 



From: "huteng.ht" <huteng.ht@xxxxxxxxxxxxx>

Since poll method in blk_mq_ops may not be implemented by driver,
add a judgement to avoid NULL pointer access.

Signed-off-by: huteng.ht <huteng.ht@xxxxxxxxxxxxx>
---
 block/blk-mq.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index c5cf0dbca1db..f58f166d1c75 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4897,6 +4897,8 @@ static int blk_mq_poll_classic(struct request_queue *q, blk_qc_t cookie,
 	int ret;
 
 	do {
+		if (!q->mq_ops->poll)
+			break;
 		ret = q->mq_ops->poll(hctx, iob);
 		if (ret > 0) {
 			__set_current_state(TASK_RUNNING);
-- 
2.20.1




[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