aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-serial-bus.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2011-02-04 14:24:18 +0530
committerAnthony Liguori <aliguori@us.ibm.com>2011-02-04 06:33:26 -0600
commit7185f9315bcf90e99b123370cf4d19b8c20afbd5 (patch)
tree7f921ec4aae1817bc99915c95ecede064a1b0e34 /hw/virtio-serial-bus.c
parent4e79bcbb96d3c189e50adbdac7b1e28d834ba43e (diff)
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 <quintela@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-serial-bus.c')
-rw-r--r--hw/virtio-serial-bus.c3
1 files changed, 3 insertions, 0 deletions
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);
}