Message ID | 20201104102248.32168-2-its@irrelevant.dk |
---|---|
State | New |
Headers | show |
Series | [for-5.2,1/3] hw/block/nvme: fix null ns in register namespace | expand |
On 04.11.20 11:22, 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(-) Reviewed-by: Max Reitz <mreitz@redhat.com>
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; > } >
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; break; }