]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: Don't mangle @cfg refs in virLXCProcessBuildControllerCmd
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 25 Jul 2018 12:48:13 +0000 (14:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 26 Jul 2018 12:18:35 +0000 (14:18 +0200)
The config object is refed but unrefed only on error which leaves
refcount unbalanced on successful return.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/lxc/lxc_process.c

index 3e44da1aaf649723f50fd5a43bd69b281df9f0e9..d021a890f7dfafba31bb6e4cbe932d862df49dc0 100644 (file)
@@ -931,7 +931,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
         filterstr = virLogGetFilters();
         if (!filterstr) {
             virReportOOMError();
-            goto cleanup;
+            goto error;
         }
 
         virCommandAddEnvPair(cmd, "LIBVIRT_LOG_FILTERS", filterstr);
@@ -943,7 +943,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
             outputstr = virLogGetOutputs();
             if (!outputstr) {
                 virReportOOMError();
-                goto cleanup;
+                goto error;
             }
 
             virCommandAddEnvPair(cmd, "LIBVIRT_LOG_OUTPUTS", outputstr);
@@ -973,7 +973,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
             char *tmp = NULL;
             if (virAsprintf(&tmp, "--share-%s",
                             nsInfoLocal[i]) < 0)
-                goto cleanup;
+                goto error;
             virCommandAddArg(cmd, tmp);
             virCommandAddArgFormat(cmd, "%d", nsInheritFDs[i]);
             virCommandPassFD(cmd, nsInheritFDs[i], 0);
@@ -999,11 +999,13 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
      * write the live domain status XML with the PID */
     virCommandRequireHandshake(cmd);
 
-    return cmd;
  cleanup:
-    virCommandFree(cmd);
     virObjectUnref(cfg);
-    return NULL;
+    return cmd;
+ error:
+    virCommandFree(cmd);
+    cmd = NULL;
+    goto cleanup;
 }