virtio-serial-bus: assert port is non-null in remove_port()

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>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
Amit Shah 2012-12-18 13:08:33 +05:30
parent 4e28976e56
commit 91bdd1cf08

View File

@ -852,6 +852,12 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)
vser->ports_map[i] &= ~(1U << (port_id % 32)); vser->ports_map[i] &= ~(1U << (port_id % 32));
port = find_port_by_id(vser, port_id); 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 */ /* Flush out any unconsumed buffers first */
discard_vq_data(port->ovq, &port->vser->vdev); discard_vq_data(port->ovq, &port->vser->vdev);