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