mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 23:55:23 +00:00
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:
parent
b51804535a
commit
344582a8a7
@ -310,6 +310,7 @@ bhyveDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -335,6 +336,7 @@ bhyveDomainGetState(virDomainPtr domain,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -355,6 +357,7 @@ bhyveDomainGetAutostart(virDomainPtr domain, int *autostart)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -418,6 +421,7 @@ bhyveDomainSetAutostart(virDomainPtr domain, int autostart)
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(configFile);
|
VIR_FREE(configFile);
|
||||||
VIR_FREE(autostartLink);
|
VIR_FREE(autostartLink);
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -437,6 +441,7 @@ bhyveDomainIsActive(virDomainPtr domain)
|
|||||||
ret = virDomainObjIsActive(obj);
|
ret = virDomainObjIsActive(obj);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (obj)
|
||||||
virObjectUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -456,6 +461,7 @@ bhyveDomainIsPersistent(virDomainPtr domain)
|
|||||||
ret = obj->persistent;
|
ret = obj->persistent;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (obj)
|
||||||
virObjectUnlock(obj);
|
virObjectUnlock(obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -475,6 +481,7 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
ret = virDomainDefFormat(vm->def, flags);
|
ret = virDomainDefFormat(vm->def, flags);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -748,6 +755,7 @@ bhyveDomainLookupByUUID(virConnectPtr conn,
|
|||||||
dom->id = vm->def->id;
|
dom->id = vm->def->id;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return dom;
|
return dom;
|
||||||
}
|
}
|
||||||
@ -775,6 +783,7 @@ static virDomainPtr bhyveDomainLookupByName(virConnectPtr conn,
|
|||||||
dom->id = vm->def->id;
|
dom->id = vm->def->id;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return dom;
|
return dom;
|
||||||
}
|
}
|
||||||
@ -803,6 +812,7 @@ bhyveDomainLookupByID(virConnectPtr conn,
|
|||||||
dom->id = vm->def->id;
|
dom->id = vm->def->id;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return dom;
|
return dom;
|
||||||
}
|
}
|
||||||
@ -844,6 +854,7 @@ bhyveDomainCreateWithFlags(virDomainPtr dom,
|
|||||||
VIR_DOMAIN_EVENT_STARTED_BOOTED);
|
VIR_DOMAIN_EVENT_STARTED_BOOTED);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
if (event)
|
if (event)
|
||||||
virObjectEventStateQueue(privconn->domainEventState, event);
|
virObjectEventStateQueue(privconn->domainEventState, event);
|
||||||
@ -999,6 +1010,7 @@ bhyveDomainOpenConsole(virDomainPtr dom,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user