hw/block/nvme: fix null ns in register namespace
Fix dereference after NULL check.
Reported-by: Coverity (CID 1436128)
Fixes: b20804946b
("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>
This commit is contained in:
parent
3441ad4bc4
commit
8ce648056f
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user