diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index 19a335c305c160e3dc2a40609d58b15b72c5acb6..f461ff6bf692165e3217060836e3500ccbae2a26 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){