From: huteng19901016@gmail.com
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"huteng.ht" <huteng.ht@bytedance.com>
Subject: [PATCH] blk-mq: fix possible NULL pointer access in classic polling
Date: Fri, 16 Dec 2022 23:06:36 +0800 [thread overview]
Message-ID: <20221216150636.18111-1-huteng.ht@bytedance.com> (raw)
From: "huteng.ht" <huteng.ht@bytedance.com>
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@bytedance.com>
---
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
next reply other threads:[~2022-12-16 15:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 15:06 huteng19901016 [this message]
2022-12-16 15:15 ` Keith Busch
2022-12-16 15:15 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221216150636.18111-1-huteng.ht@bytedance.com \
--to=huteng19901016@gmail.com \
--cc=axboe@kernel.dk \
--cc=huteng.ht@bytedance.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®