From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Fam Zheng <famz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH] nvme: Make nvme_init error handling code more readable
Date: Mon, 21 May 2018 14:35:16 +0800 [thread overview]
Message-ID: <20180521063516.5479-1-famz@redhat.com> (raw)
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
next reply other threads:[~2018-05-21 6:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 6:35 Fam Zheng [this message]
2018-05-21 8:35 ` [Qemu-devel] [PATCH] nvme: Make nvme_init error handling code more readable 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180521063516.5479-1-famz@redhat.com \
--to=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).