qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] nvme: Make nvme_init error handling code more readable
@ 2018-05-21  6:35 Fam Zheng
  2018-05-21  8:35 ` Peter Maydell
  2018-05-24 17:16 ` Paolo Bonzini
  0 siblings, 2 replies; 9+ messages in thread
From: Fam Zheng @ 2018-05-21  6:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Fam Zheng, Kevin Wolf, Max Reitz, qemu-block

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>
---
 block/nvme.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/block/nvme.c b/block/nvme.c
index 6f71122bf5..8239b920c8 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -560,6 +560,13 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
     qemu_co_queue_init(&s->dma_flush_queue);
     s->nsid = namespace;
     s->aio_context = bdrv_get_aio_context(bs);
+
+    /* Fields we've not touched should be zero-initialized by block layer
+     * already, but reset them anyway to make the error handling code easier to
+     * reason. */
+    s->regs = NULL;
+    s->vfio = NULL;
+
     ret = event_notifier_init(&s->irq_notifier, 0);
     if (ret) {
         error_setg(errp, "Failed to init event notifier");
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-05-25 13:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-21  6:35 [Qemu-devel] [PATCH] nvme: Make nvme_init error handling code more readable Fam Zheng
2018-05-21  8:35 ` Peter Maydell
2018-05-21  8:56   ` Fam Zheng
2018-05-24 17:16 ` Paolo Bonzini
2018-05-25  2:16   ` Fam Zheng
2018-05-25  5:47     ` Markus Armbruster
2018-05-25  6:25       ` Fam Zheng
2018-05-25  7:27         ` Markus Armbruster
2018-05-25 13:07         ` Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).