From: Amit Shah <amit.shah@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>, qemu list <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 1/1] virtio-serial-bus: assert port is non-null in remove_port()
Date: Tue, 18 Dec 2012 13:13:55 +0530 [thread overview]
Message-ID: <e511f84e3897014ffe70ebb00124f028f65e098f.1355816625.git.amit.shah@redhat.com> (raw)
In-Reply-To: <87sj74stw6.fsf@blackfin.pond.sub.org>
remove_port() is called from qdev's unplug callback, and we're certain
the port will be found in our list of ports. Adding an assert()
documents this.
This was flagged by Coverity, fix suggested by Markus.
CC: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
hw/virtio-serial-bus.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 3ea95b8..ce4556f 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -852,6 +852,12 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)
vser->ports_map[i] &= ~(1U << (port_id % 32));
port = find_port_by_id(vser, port_id);
+ /*
+ * This function is only called from qdev's unplug callback; if we
+ * get a NULL port here, we're in trouble.
+ */
+ assert(port);
+
/* Flush out any unconsumed buffers first */
discard_vq_data(port->ovq, &port->vser->vdev);
--
1.8.0.2
next prev parent reply other threads:[~2012-12-18 7:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-13 11:03 [Qemu-devel] [PATCH 1/1] virtio-serial-bus: send_control_msg should not deal with cpkts Amit Shah
2012-12-17 13:14 ` Markus Armbruster
2012-12-17 16:34 ` Amit Shah
2012-12-17 17:23 ` Markus Armbruster
2012-12-17 17:31 ` Amit Shah
2012-12-18 7:31 ` Markus Armbruster
2012-12-18 7:43 ` Amit Shah [this message]
2012-12-18 8:44 ` [Qemu-devel] [PATCH 1/1] virtio-serial-bus: assert port is non-null in remove_port() Markus Armbruster
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=e511f84e3897014ffe70ebb00124f028f65e098f.1355816625.git.amit.shah@redhat.com \
--to=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--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).