bhyve: fix virObjectUnlock() usage

In a number of places in the bhyve driver, virObjectUnlock()
is called with an arg without check if the arg is non-NULL, which
could result in passing NULL value and a warning like:

virObjectUnlock:340 : Object 0x0 ((unknown)) is not a virObjectLockable instance

* src/bhyve/bhyve_driver.c (bhyveDomainGetInfo)
(bhyveDomainGetState, bhyveDomainGetAutostart)
(bhyveDomainSetAutostart, bhyveDomainIsActive)
(bhyveDomainIsPersistent, bhyveDomainGetXMLDesc)
(bhyveDomainUndefine, bhyveDomainLookupByUUID)
(bhyveDomainLookupByName, bhyveDomainLookupByID)
(bhyveDomainCreateWithFlags, bhyveDomainOpenConsole):
Check if arg is not NULL before calling virObjectUnlock on it.
This commit is contained in:
Roman Bogorodskiy 2014-05-17 23:08:14 +04:00
parent b51804535a
commit 344582a8a7

View File

@ -310,6 +310,7 @@ bhyveDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
ret = 0;
cleanup:
if (vm)
virObjectUnlock(vm);
return ret;
}
@ -335,6 +336,7 @@ bhyveDomainGetState(virDomainPtr domain,
ret = 0;
cleanup:
if (vm)
virObjectUnlock(vm);
return ret;
}
@ -355,6 +357,7 @@ bhyveDomainGetAutostart(virDomainPtr domain, int *autostart)
ret = 0;
cleanup:
if (vm)
virObjectUnlock(vm);
return ret;
}
@ -418,6 +421,7 @@ bhyveDomainSetAutostart(virDomainPtr domain, int autostart)
cleanup:
VIR_FREE(configFile);
VIR_FREE(autostartLink);
if (vm)
virObjectUnlock(vm);
return ret;
}
@ -437,6 +441,7 @@ bhyveDomainIsActive(virDomainPtr domain)
ret = virDomainObjIsActive(obj);
cleanup:
if (obj)
virObjectUnlock(obj);
return ret;
}
@ -456,6 +461,7 @@ bhyveDomainIsPersistent(virDomainPtr domain)
ret = obj->persistent;
cleanup:
if (obj)
virObjectUnlock(obj);
return ret;
}
@ -475,6 +481,7 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
ret = virDomainDefFormat(vm->def, flags);
cleanup:
if (vm)
virObjectUnlock(vm);
return ret;
}
@ -748,6 +755,7 @@ bhyveDomainLookupByUUID(virConnectPtr conn,
dom->id = vm->def->id;
cleanup:
if (vm)
virObjectUnlock(vm);
return dom;
}
@ -775,6 +783,7 @@ static virDomainPtr bhyveDomainLookupByName(virConnectPtr conn,
dom->id = vm->def->id;
cleanup:
if (vm)
virObjectUnlock(vm);
return dom;
}
@ -803,6 +812,7 @@ bhyveDomainLookupByID(virConnectPtr conn,
dom->id = vm->def->id;
cleanup:
if (vm)
virObjectUnlock(vm);
return dom;
}
@ -844,6 +854,7 @@ bhyveDomainCreateWithFlags(virDomainPtr dom,
VIR_DOMAIN_EVENT_STARTED_BOOTED);
cleanup:
if (vm)
virObjectUnlock(vm);
if (event)
virObjectEventStateQueue(privconn->domainEventState, event);
@ -999,6 +1010,7 @@ bhyveDomainOpenConsole(virDomainPtr dom,
ret = 0;
cleanup:
if (vm)
virObjectUnlock(vm);
return ret;
}