aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorOrit Wassermann <owasserm@redhat.com>2012-05-16 12:21:35 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2012-05-21 15:40:50 -0500
commit2a633c461e96cb9a856292c46917653bd43959c8 (patch)
tree2907c129ba38047391cea14d072594f866479450 /hw
parenta6c5c84ae25bc68f22725f77d6d77c98af5c4f9e (diff)
virtio: check virtio_load return code
Otherwise we crash on error. Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com> Signed-off-by: Orit Wassermann <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/virtio-balloon.c6
-rw-r--r--hw/virtio-blk.c7
-rw-r--r--hw/virtio-net.c6
-rw-r--r--hw/virtio-scsi.c7
-rw-r--r--hw/virtio-serial-bus.c6
5 files changed, 27 insertions, 5 deletions
diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index ce9d2c9759..075ed87e37 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -211,11 +211,15 @@ static void virtio_balloon_save(QEMUFile *f, void *opaque)
static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
{
VirtIOBalloon *s = opaque;
+ int ret;
if (version_id != 1)
return -EINVAL;
- virtio_load(&s->vdev, f);
+ ret = virtio_load(&s->vdev, f);
+ if (ret) {
+ return ret;
+ }
s->num_pages = qemu_get_be32(f);
s->actual = qemu_get_be32(f);
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 9f605d37cb..f9e1896ea9 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -533,11 +533,16 @@ static void virtio_blk_save(QEMUFile *f, void *opaque)
static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
{
VirtIOBlock *s = opaque;
+ int ret;
if (version_id != 2)
return -EINVAL;
- virtio_load(&s->vdev, f);
+ ret = virtio_load(&s->vdev, f);
+ if (ret) {
+ return ret;
+ }
+
while (qemu_get_sbyte(f)) {
VirtIOBlockReq *req = virtio_blk_alloc_request(s);
qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem));
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index bc5e3a83d1..3f190d417e 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -891,11 +891,15 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
{
VirtIONet *n = opaque;
int i;
+ int ret;
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
return -EINVAL;
- virtio_load(&n->vdev, f);
+ ret = virtio_load(&n->vdev, f);
+ if (ret) {
+ return ret;
+ }
qemu_get_buffer(f, n->mac, ETH_ALEN);
n->tx_waiting = qemu_get_be32(f);
diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
index e8328f4652..5e39ce93c4 100644
--- a/hw/virtio-scsi.c
+++ b/hw/virtio-scsi.c
@@ -564,7 +564,12 @@ static void virtio_scsi_save(QEMUFile *f, void *opaque)
static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)
{
VirtIOSCSI *s = opaque;
- virtio_load(&s->vdev, f);
+ int ret;
+
+ ret = virtio_load(&s->vdev, f);
+ if (ret) {
+ return ret;
+ }
return 0;
}
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index ffbdfc2de1..72287d10ce 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -637,13 +637,17 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
VirtIOSerialPort *port;
uint32_t max_nr_ports, nr_active_ports, ports_map;
unsigned int i;
+ int ret;
if (version_id > 3) {
return -EINVAL;
}
/* The virtio device */
- virtio_load(&s->vdev, f);
+ ret = virtio_load(&s->vdev, f);
+ if (ret) {
+ return ret;
+ }
if (version_id < 2) {
return 0;