qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Klaus Jensen <its@irrelevant.dk>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	qemu-block@nongnu.org, Dmitry Fomichev <dmitry.fomichev@wdc.com>,
	Klaus Jensen <k.jensen@samsung.com>,
	Max Reitz <mreitz@redhat.com>,
	Minwoo Im <minwoo.im.dev@gmail.com>,
	Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH for-5.2 1/3] hw/block/nvme: fix null ns in register namespace
Date: Wed, 4 Nov 2020 12:08:22 +0100	[thread overview]
Message-ID: <db19077f-e8a9-0a59-7f7d-7b1ccbaf1b5b@redhat.com> (raw)
In-Reply-To: <20201104102248.32168-2-its@irrelevant.dk>

On 11/4/20 11:22 AM, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Fix dereference after NULL check.
> 
> Reported-by: Coverity (CID 1436128)
> Fixes: b20804946bce ("hw/block/nvme: update nsid when registered")
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>  hw/block/nvme.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index fa2cba744b57..080d782f1c2b 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -2562,8 +2562,7 @@ int nvme_register_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp)
>  
>      if (!nsid) {
>          for (int i = 1; i <= n->num_namespaces; i++) {
> -            NvmeNamespace *ns = nvme_ns(n, i);
> -            if (!ns) {
> +            if (!nvme_ns(n, i)) {
>                  nsid = ns->params.nsid = i;

Uh.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>                  break;
>              }
> 



  parent reply	other threads:[~2020-11-04 11:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 10:22 [PATCH for-5.2 0/3] hw/block/nvme: coverity fixes Klaus Jensen
2020-11-04 10:22 ` [PATCH for-5.2 1/3] hw/block/nvme: fix null ns in register namespace Klaus Jensen
2020-11-04 10:57   ` Max Reitz
2020-11-04 11:08   ` Philippe Mathieu-Daudé [this message]
2020-11-04 10:22 ` [PATCH for-5.2 2/3] hw/block/nvme: fix uint16_t use of uint32_t sgls member Klaus Jensen
2020-11-04 10:58   ` Max Reitz
2020-11-04 11:09   ` Philippe Mathieu-Daudé
2020-11-04 10:22 ` [PATCH for-5.2 3/3] hw/block/nvme: fix free of array-typed value Klaus Jensen
2020-11-04 10:51   ` Philippe Mathieu-Daudé
2020-11-04 10:59   ` Max Reitz
2020-11-04 11:04     ` Klaus Jensen
2020-11-04 11:10       ` Max Reitz
2020-11-04 11:11 ` [PATCH for-5.2 0/3] hw/block/nvme: coverity fixes Max Reitz

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=db19077f-e8a9-0a59-7f7d-7b1ccbaf1b5b@redhat.com \
    --to=philmd@redhat.com \
    --cc=dmitry.fomichev@wdc.com \
    --cc=its@irrelevant.dk \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=minwoo.im.dev@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).