[PATCH 04/11] network: Remove conditional settings to resolve resource leak

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

 



The conditional setting of cmdout in networkBuildDhcpDaemonCommandLine()
caused Coverity to complain that 'cmd' could be leaked if !cmdout.  Since
the function is local and only called with cmdout being passed those checks
have been removed.
---
 src/network/bridge_driver.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 21255f0..e9a36e5 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -995,7 +995,8 @@ cleanup:
 
 /* build the dnsmasq command line */
 static int
-networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, virCommandPtr *cmdout,
+networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network,
+                                  virCommandPtr *cmdout,
                                   char *pidfile, dnsmasqContext *dctx,
                                   dnsmasqCapsPtr caps)
 {
@@ -1027,13 +1028,9 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, virCommandPtr *cmdou
 
     cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps));
     virCommandAddArgFormat(cmd, "--conf-file=%s", configfile);
-
-    if (cmdout)
-        *cmdout = cmd;
+    *cmdout = cmd;
     ret = 0;
 cleanup:
-    if (ret < 0)
-        virCommandFree(cmd);
     return ret;
 }
 
-- 
1.7.11.7

--
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]