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