From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkrqT-0000dP-1m for qemu-devel@nongnu.org; Tue, 18 Dec 2012 02:44:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkrqS-0000ZB-3I for qemu-devel@nongnu.org; Tue, 18 Dec 2012 02:44:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkrqR-0000Z2-SS for qemu-devel@nongnu.org; Tue, 18 Dec 2012 02:44:08 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBI7i55C006175 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Dec 2012 02:44:06 -0500 From: Amit Shah Date: Tue, 18 Dec 2012 13:13:55 +0530 Message-Id: In-Reply-To: <87sj74stw6.fsf@blackfin.pond.sub.org> References: <87sj74stw6.fsf@blackfin.pond.sub.org> Subject: [Qemu-devel] [PATCH 1/1] virtio-serial-bus: assert port is non-null in remove_port() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Amit Shah , qemu list 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 Signed-off-by: Amit Shah --- 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