public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Sapozhnikov <alsp705@gmail.com>
To: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>
Cc: Alexandr Sapozhnikov <alsp705@gmail.com>,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: [PATCH] drivers: nvme: target: core: deref after null
Date: Fri,  7 Jun 2024 16:43:39 +0300	[thread overview]
Message-ID: <20240607134340.11-1-alsp705@gmail.com> (raw)

From: Alexandr Sapozhnikov <alsp705@gmail.com>

After having been compared to a NULL value at core.c:813, 
pointer '(**sq->ctrl).sqs' is dereferenced at core.c:838.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
---
 drivers/nvme/target/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 06f0c587f343..5a67d2bc0c55 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -827,7 +827,7 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)
 	 */
 	ctrl = sq->ctrl;
 
-	if (ctrl) {
+	if (ctrl && ctrl->sqs) {
 		/*
 		 * The teardown flow may take some time, and the host may not
 		 * send us keep-alive during this period, hence reset the
-- 
2.39.2


             reply	other threads:[~2024-06-07 13:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 13:43 Alexander Sapozhnikov [this message]
2024-06-10  4:34 ` [PATCH] drivers: nvme: target: core: deref after null Chaitanya Kulkarni
2024-06-10  6:54 ` Markus Elfring
2024-06-10 10:02 ` Sagi Grimberg

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=20240607134340.11-1-alsp705@gmail.com \
    --to=alsp705@gmail.com \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=sagi@grimberg.me \
    /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