[PATCH 2/6] Fix possible memory leak in phyp_driver.c

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

 



There could be a memory leak caused by "managed_system" string, if any
error occurs before "managed_system" is assigned into
"phyp_driver->managed_system". The "managed_system" string wouldn't be
freed at all. The better way is free the "managed_system" instead
of the one assigned in the "phyp_driver".

This has been found by coverity.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/phyp/phyp_driver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 32165ed..6833e44 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1153,9 +1153,11 @@ phypConnectOpen(virConnectPtr conn,
     return VIR_DRV_OPEN_SUCCESS;
 
 failure:
+    if (conn->uri->path)
+        VIR_FREE(managed_system);
+
     if (phyp_driver != NULL) {
         virObjectUnref(phyp_driver->caps);
-        VIR_FREE(phyp_driver->managed_system);
         VIR_FREE(phyp_driver);
     }
 
-- 
1.8.3.1

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