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

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



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 redhat com>
---
 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


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