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