]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: Fix possible leaked @vm in lxcDomainCreateXMLWithFiles
authorJohn Ferlan <jferlan@redhat.com>
Mon, 2 Apr 2018 14:03:02 +0000 (10:03 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 11 Apr 2018 15:27:15 +0000 (11:27 -0400)
In error paths, if we call virDomainObjListRemove we will leak
the @vm because we have called with a reffed and locked @vm.
So rather than set it to NULL, relock the @vm and allow the
virDomainObjEndAPI to perform the magic of Unlock/Unref.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/lxc/lxc_driver.c

index 4f600f3df75745909e94ccdd226b7f53121f4c47..54f853cbae56365b264608fad61b930d6f068b94 100644 (file)
@@ -1245,7 +1245,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
     if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) {
         if (!vm->persistent) {
             virDomainObjListRemove(driver->domains, vm);
-            vm = NULL;
+            virObjectLock(vm);
         }
         goto cleanup;
     }
@@ -1258,7 +1258,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
         virLXCDomainObjEndJob(driver, vm);
         if (!vm->persistent) {
             virDomainObjListRemove(driver->domains, vm);
-            vm = NULL;
+            virObjectLock(vm);
         }
         goto cleanup;
     }