[PATCH 14/14] hyperv: Address resource leak found by Coverityo

[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/hyperv/hyperv_driver.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 601a85a..e69a232 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -121,6 +121,7 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
         virReportOOMError();
         goto cleanup;
     }
+    conn->privateData = priv;
 
     if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) {
         goto cleanup;
@@ -199,18 +200,17 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
         goto cleanup;
     }
 
-    conn->privateData = priv;
-
     result = VIR_DRV_OPEN_SUCCESS;
 
   cleanup:
-    if (result == VIR_DRV_OPEN_ERROR) {
-        hypervFreePrivate(&priv);
-    }
+    if (result == VIR_DRV_OPEN_ERROR)
+        conn->privateData = NULL;
 
     VIR_FREE(username);
     VIR_FREE(password);
     hypervFreeObject(priv, (hypervObject *)computerSystem);
+    if (priv && !conn->privateData)
+        hypervFreePrivate(&priv);
 
     return result;
 }
-- 
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]