aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2011-03-22 18:32:50 +0200
committerMichael S. Tsirkin <mst@redhat.com>2011-03-28 18:34:23 +0200
commitfbe0c5591077814eead05217fc96f087b254a6a8 (patch)
tree36d36b88718a4e480f29a3a4ff53a40c3dfbac15 /hw
parent6cdfab2868dd593902e2b7db3ba9f49f2cc03e3f (diff)
virtio-serial: don't crash on invalid input
Fix crash on invalid input in virtio-serial. Discovered by code review, untested. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw')
-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 a82fbe9ba4..62273799b6 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -594,6 +594,9 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
id = qemu_get_be32(f);
port = find_port_by_id(s, id);
+ if (!port) {
+ return -EINVAL;
+ }
port->guest_connected = qemu_get_byte(f);
host_connected = qemu_get_byte(f);