From 7185f9315bcf90e99b123370cf4d19b8c20afbd5 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Fri, 4 Feb 2011 14:24:18 +0530 Subject: virtio-serial: Make sure virtqueue is ready before discarding data This can happen if a port gets unplugged before guest has chance to initialise vqs. Reported-by: Juan Quintela Signed-off-by: Amit Shah Signed-off-by: Anthony Liguori --- hw/virtio-serial-bus.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'hw/virtio-serial-bus.c') diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 09e22aa44a..e05ab5e609 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -117,6 +117,9 @@ static void discard_vq_data(VirtQueue *vq, VirtIODevice *vdev) { VirtQueueElement elem; + if (!virtio_queue_ready(vq)) { + return; + } while (virtqueue_pop(vq, &elem)) { virtqueue_push(vq, &elem, 0); } -- cgit v1.2.3