]> Git Repo - qemu.git/commitdiff
virtio-serial-bus: assert port is non-null in remove_port()
authorAmit Shah <[email protected]>
Tue, 18 Dec 2012 07:38:33 +0000 (13:08 +0530)
committerAmit Shah <[email protected]>
Tue, 18 Dec 2012 08:58:50 +0000 (14:28 +0530)
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 <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Amit Shah <[email protected]>
hw/virtio-serial-bus.c

index 3ea95b8b52bbc980aae5c6c7c2e123b966247d64..ce4556fc4849b34965eca3c1a1b3c67bab2c7122 100644 (file)
@@ -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);
 
This page took 0.03737 seconds and 4 git commands to generate.