1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-04-01 20:05:19 +00:00

ch_driver: Handle validation failure correctly

When validation like deviceValidateCallback fails, the vm will not be
set and so the call to virDomainObjListRemove will be passed a NULL
pointer causing a segfault. To prevent this add a check that the vm is
defined before calling out to virDomainObjListRemove.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
This commit is contained in:
William Douglas 2021-09-08 11:01:23 -07:00 committed by Daniel P. Berrangé
parent d4f047dbd1
commit c88b26a656

View File

@ -262,7 +262,7 @@ chDomainCreateXML(virConnectPtr conn,
virCHDomainObjEndJob(vm);
cleanup:
if (!dom) {
if (vm && !dom) {
virDomainObjListRemove(driver->domains, vm);
}
virDomainDefFree(vmdef);