From: Sagi Grimberg <sagi@grimberg.me>
To: Alexander Sapozhnikov <alsp705@gmail.com>,
Christoph Hellwig <hch@lst.de>,
Chaitanya Kulkarni <kch@nvidia.com>
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] drivers: nvme: target: core: deref after null
Date: Mon, 10 Jun 2024 13:02:39 +0300 [thread overview]
Message-ID: <fe0a1e51-8b88-4f6d-98ec-a5e6c2a12e8d@grimberg.me> (raw)
In-Reply-To: <20240607134340.11-1-alsp705@gmail.com>
On 07/06/2024 16:43, Alexander Sapozhnikov wrote:
> 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
This is a redundant check. sq->ctrl and sq->ctrl->sqs have the same
lifetime. If
sq->ctrl was assigned, it means that it was allocated and needs a final
put to
fully cleanup. ctrl->sqs is allocated in nvmet_alloc_ctrl and freed in
nvmet_free_ctrl
which is the final reference.
prev parent reply other threads:[~2024-06-10 10:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-07 13:43 Alexander Sapozhnikov
2024-06-10 4:34 ` Chaitanya Kulkarni
2024-06-10 6:54 ` Markus Elfring
2024-06-10 10:02 ` Sagi Grimberg [this message]
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=fe0a1e51-8b88-4f6d-98ec-a5e6c2a12e8d@grimberg.me \
--to=sagi@grimberg.me \
--cc=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 \
/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®