[v2] nvme: Make nvme_init error handling code more readable
diff mbox series

Message ID 20180521085834.15632-1-famz@redhat.com
State New
Headers show
Series
  • [v2] nvme: Make nvme_init error handling code more readable
Related show

Commit Message

Fam Zheng May 21, 2018, 8:58 a.m. UTC
Coverity doesn't like the tests under fail label (report CID 1385847).
Reset the fields so the clean up order is more apparent.

Signed-off-by: Fam Zheng <famz@redhat.com>

---

v2: Don't play stupid. [Peter]
---
 block/nvme.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Fam Zheng May 24, 2018, 7:46 a.m. UTC | #1
On Mon, 05/21 16:58, Fam Zheng wrote:
> Coverity doesn't like the tests under fail label (report CID 1385847).
> Reset the fields so the clean up order is more apparent.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>

Queued, thanks.

Fam

Patch
diff mbox series

diff --git a/block/nvme.c b/block/nvme.c
index 6f71122bf5..c2eb9e2a4e 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -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;