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
This commit is contained in:
Matthias Bolte 2009-11-03 00:54:09 +01:00
parent 5469686bfd
commit 0f04b58730

View File

@ -617,23 +617,26 @@ static int oneStartup(int privileged ATTRIBUTE_UNUSED){
return -1;
}
if (virDomainObjListInit(&one_driver->domains) < 0) {
virMutexDestroy(&one_driver->lock);
VIR_FREE(one_driver);
return -1;
}
c_oneStart();
oneDriverLock(one_driver);
if (virDomainObjListInit(&one_driver->domains) < 0) {
goto error;
}
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){