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

[libvirt] [PATCH] opennebula: Fix potential memory/mutex leak in state driver startup



In case of an error the domains hash and the driver mutex may leak.

* src/opennebula/one_driver.c: free/destroy domains hash and driver
  mutex in error cases
---
 src/opennebula/one_driver.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index 19a335c..f461ff6 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -617,23 +617,26 @@ static int oneStartup(int privileged ATTRIBUTE_UNUSED){
         return -1;
     }
 
+    c_oneStart();
+    oneDriverLock(one_driver);
+
     if (virDomainObjListInit(&one_driver->domains) < 0) {
-        virMutexDestroy(&one_driver->lock);
-        VIR_FREE(one_driver);
-        return -1;
+        goto error;
     }
 
-    c_oneStart();
-    oneDriverLock(one_driver);
     one_driver->nextid=1;
     if ((one_driver->caps = oneCapsInit()) == NULL) {
-        oneDriverUnlock(one_driver);
-        VIR_FREE(one_driver);
-        return -1;
+        virReportOOMError(NULL);
+        goto error;
     }
     oneDriverUnlock(one_driver);
 
     return 0;
+
+error:
+    oneDriverUnlock(one_driver);
+    oneShutdown();
+    return -1;
 }
 
 static int oneShutdown(void){
-- 
1.6.0.4


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