diff options
author | Klaus Jensen <k.jensen@samsung.com> | 2020-11-04 11:22:46 +0100 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2020-11-09 15:44:21 +0100 |
commit | 8ce648056fe2e1b071579b66401c8a58ecbebe05 (patch) | |
tree | cad084fae444ff200f52918b21f4e810145ae979 | |
parent | 3441ad4bc42ce9d9c6004cd013b91da0a454f143 (diff) | |
download | qemu-8ce648056fe2e1b071579b66401c8a58ecbebe05.zip qemu-8ce648056fe2e1b071579b66401c8a58ecbebe05.tar.gz qemu-8ce648056fe2e1b071579b66401c8a58ecbebe05.tar.bz2 |
hw/block/nvme: fix null ns in register namespace
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>
Message-Id: <20201104102248.32168-2-its@irrelevant.dk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
-rw-r--r-- | hw/block/nvme.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index fa2cba7..080d782 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; break; } |