diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2013-09-10 18:21:08 +0200 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2013-12-09 11:40:30 -0600 |
commit | 03060dc086ec8a75929b7bb58df9e67a305a810d (patch) | |
tree | d61e44e9c7e1c29e9df73300626046cdeb88a587 | |
parent | 2cafbbf1e03b954dedd3643ab3a4ffe685a63ccf (diff) | |
download | qemu-03060dc086ec8a75929b7bb58df9e67a305a810d.zip qemu-03060dc086ec8a75929b7bb58df9e67a305a810d.tar.gz qemu-03060dc086ec8a75929b7bb58df9e67a305a810d.tar.bz2 |
qdev-monitor: Unref device when device_add fails
qdev_device_add() leaks the created device upon failure. I suspect this
problem crept in because qdev_free() unparents the device but does not
drop a reference - confusing name.
Cc: qemu-stable@nongnu.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
(cherry picked from commit ee6abeb6ec08473713848ce9028110f1684853b7)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r-- | qdev-monitor.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/qdev-monitor.c b/qdev-monitor.c index bb2e1b6..1b2c606 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -518,6 +518,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) } if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) { qdev_free(qdev); + object_unref(OBJECT(qdev)); return NULL; } if (qdev->id) { @@ -531,6 +532,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) g_free(name); } if (qdev_init(qdev) < 0) { + object_unref(OBJECT(qdev)); qerror_report(QERR_DEVICE_INIT_FAILED, driver); return NULL; } |