cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-qdev-monitor-Unref-device-when-device_add-fails.patch

0a122b
From 527da6c2ce2c09d0183aa8595fc95f136f61b6df Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <527da6c2ce2c09d0183aa8595fc95f136f61b6df.1387288155.git.minovotn@redhat.com>
0a122b
From: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Date: Thu, 12 Dec 2013 16:21:21 +0100
0a122b
Subject: [PATCH 1/8] qdev-monitor: Unref device when device_add fails
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Message-id: <1386865288-1575-2-git-send-email-stefanha@redhat.com>
0a122b
Patchwork-id: 56255
0a122b
O-Subject: [RHEL7 qemu-kvm PATCH 1/8] qdev-monitor: Unref device when device_add fails
0a122b
Bugzilla: 1003773
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
0a122b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
0a122b
0a122b
qdev_device_add() leaks the created device upon failure.  I suspect this
0a122b
problem crept in because qdev_free() unparents the device but does not
0a122b
drop a reference - confusing name.
0a122b
0a122b
Cc: qemu-stable@nongnu.org
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Reviewed-by: Eric Blake <eblake@redhat.com>
0a122b
Signed-off-by: Andreas Färber <afaerber@suse.de>
0a122b
(cherry picked from commit ee6abeb6ec08473713848ce9028110f1684853b7)
0a122b
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
---
0a122b
 qdev-monitor.c | 2 ++
0a122b
 1 file changed, 2 insertions(+)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 qdev-monitor.c | 2 ++
0a122b
 1 file changed, 2 insertions(+)
0a122b
0a122b
diff --git a/qdev-monitor.c b/qdev-monitor.c
0a122b
index 39d030b..9d4f61d 100644
0a122b
--- a/qdev-monitor.c
0a122b
+++ b/qdev-monitor.c
0a122b
@@ -522,6 +522,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
0a122b
     }
0a122b
     if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
0a122b
         qdev_free(qdev);
0a122b
+        object_unref(OBJECT(qdev));
0a122b
         return NULL;
0a122b
     }
0a122b
     if (qdev->id) {
0a122b
@@ -535,6 +536,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
0a122b
         g_free(name);
0a122b
     }        
0a122b
     if (qdev_init(qdev) < 0) {
0a122b
+        object_unref(OBJECT(qdev));
0a122b
         qerror_report(QERR_DEVICE_INIT_FAILED, driver);
0a122b
         return NULL;
0a122b
     }
0a122b
-- 
0a122b
1.7.11.7
0a122b