[PATCH 10/12] qemu: hotplug: Fix possible memory leak of props

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If we failed to build the aliases or attach the chardev, then the props
would be leaked - fix that.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b6cf196..c82d455 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1685,6 +1685,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
 
     if (qemuMonitorAddObject(priv->mon, type, objAlias, props) < 0)
         goto failbackend;
+    props = NULL;
 
     if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
         goto failfrontend;
@@ -1702,6 +1703,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
  audit:
     virDomainAuditRNG(vm, NULL, rng, "attach", ret == 0);
  cleanup:
+    virJSONValueFree(props);
     if (ret < 0 && vm)
         qemuDomainReleaseDeviceAddress(vm, &rng->info, NULL);
     VIR_FREE(charAlias);
@@ -1715,6 +1717,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
  failbackend:
     if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD)
         ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
+    props = NULL;  /* qemuMonitorAddObject consumes on failure */
  failchardev:
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         vm = NULL;
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]