]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: hotplug: Fix possible memory leak of props
authorJohn Ferlan <jferlan@redhat.com>
Mon, 11 Apr 2016 14:00:32 +0000 (10:00 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 2 May 2016 10:29:21 +0000 (06:29 -0400)
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@redhat.com>
src/qemu/qemu_hotplug.c

index ec9f4da9a6083ebff579ecd3f5344fdbaa32ffeb..3c9cd3537f96160adf212e95e266b46c67167da0 100644 (file)
@@ -1650,6 +1650,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
 
     if (qemuMonitorAddObject(priv->mon, type, objAlias, props) < 0)
         goto failbackend;
+    props = NULL;
 
     if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
         goto failfrontend;
@@ -1667,6 +1668,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);
@@ -1680,6 +1682,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;