9ae3a8
From 590c54266333cf9b147144d80999086dc877aba3 Mon Sep 17 00:00:00 2001
9ae3a8
From: Amos Kong <akong@redhat.com>
9ae3a8
Date: Mon, 4 Aug 2014 03:16:39 +0200
9ae3a8
Subject: [PATCH 3/4] virtio-rng: check return value of virtio_load()
9ae3a8
9ae3a8
Message-id: <1407122199-6365-1-git-send-email-akong@redhat.com>
9ae3a8
Patchwork-id: 60412
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH] virtio-rng: check return value of virtio_load()
9ae3a8
Bugzilla: 1116941
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
9ae3a8
Bugzilla: 1116941
9ae3a8
Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7780748
9ae3a8
Upstream: it's fixed by commit 3902d49e, we don't need to
9ae3a8
          backport whole patch.
9ae3a8
9ae3a8
virtio_load() might fail, we should check the return value.
9ae3a8
9ae3a8
Signed-off-by: Amos Kong <akong@redhat.com>
9ae3a8
---
9ae3a8
 hw/virtio/virtio-rng.c |    7 ++++++-
9ae3a8
 1 files changed, 6 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/virtio/virtio-rng.c |    7 ++++++-
9ae3a8
 1 files changed, 6 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
9ae3a8
index 6895146..83d4a55 100644
9ae3a8
--- a/hw/virtio/virtio-rng.c
9ae3a8
+++ b/hw/virtio/virtio-rng.c
9ae3a8
@@ -108,11 +108,16 @@ static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id)
9ae3a8
 {
9ae3a8
     VirtIORNG *vrng = opaque;
9ae3a8
     VirtIODevice *vdev = VIRTIO_DEVICE(vrng);
9ae3a8
+    int ret;
9ae3a8
 
9ae3a8
     if (version_id != 1) {
9ae3a8
         return -EINVAL;
9ae3a8
     }
9ae3a8
-    virtio_load(vdev, f);
9ae3a8
+
9ae3a8
+    ret = virtio_load(vdev, f);
9ae3a8
+    if (ret) {
9ae3a8
+        return ret;
9ae3a8
+    }
9ae3a8
 
9ae3a8
     /* We may have an element ready but couldn't process it due to a quota
9ae3a8
      * limit.  Make sure to try again after live migration when the quota may
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8