Skip to contentSkip to conversation

nvme: Make nvme_init error handling code more readable

PATCH Applied Fam Zheng 1 participant 2 messages May 21, 2018 – May 24, 2018 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v2 1/1 nvme: Make nvme_init error handling code more readable

Coverity doesn't like the tests under fail label (report CID 1385847). Reset the fields so the clean up order is more apparent.

---

v2: Don't play stupid. [Peter]

---
 block/nvme.c | 4 ++++
 1 file changed, 4 insertions(+)
block/nvme.c +4 -0
index 6f71122bf5..c2eb9e2a4e 100644
@@ -566,6 +566,10 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
         return ret;
     }
 
+    /* Fields we've not touched should be zero-initialized by block layer
+     * already, but reset it anyway to make the error handling code easier to
+     * reason. */
+    s->regs = NULL;
     s->vfio = qemu_vfio_open_pci(device, errp);
     if (!s->vfio) {
         ret = -EINVAL;
Signature · 1 line
2.14.3
author Applied
#1 lore raw
Quoted 4 lines · Fam Zheng

Coverity doesn't like the tests under fail label (report CID 1385847). Reset the fields so the clean up order is more apparent.

Queued, thanks.

Fam