[PATCH 02/14] esx: Address resource leak found by Coverity

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

 



Because result was used to determine whether or not to free 'priv'
resources Coverity tagged the code as having a resource leak. This
change addresses that concern.
---
 src/esx/esx_driver.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 1366c81..9befa38 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -998,6 +998,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth,
         virReportOOMError();
         goto cleanup;
     }
+    conn->privateData = priv;
 
     if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) {
         goto cleanup;
@@ -1008,8 +1009,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth,
     priv->supportsLongMode = esxVI_Boolean_Undefined;
     priv->usedCpuTimeCounterId = -1;
 
-    conn->privateData = priv;
-
     /*
      * Set the port dependent on the transport protocol if no port is
      * specified. This allows us to rely on the port parameter being
@@ -1104,9 +1103,10 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth,
     result = VIR_DRV_OPEN_SUCCESS;
 
   cleanup:
-    if (result == VIR_DRV_OPEN_ERROR) {
+    if (result == VIR_DRV_OPEN_ERROR)
+        conn->privateData = NULL;
+    if (priv && !conn->privateData)
         esxFreePrivate(&priv);
-    }
 
     VIR_FREE(potentialVCenterIpAddress);
 
-- 
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]