From: William Douglas Date: Wed, 8 Sep 2021 18:01:23 +0000 (-0700) Subject: ch_driver: Handle validation failure correctly X-Git-Tag: v7.8.0-rc1~260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c88b26a656a48a976300b4f0e1745058307f5a89;p=thirdparty%2Flibvirt.git 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é Signed-off-by: William Douglas --- diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index c821459fc5..1824d2fd16 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -262,7 +262,7 @@ chDomainCreateXML(virConnectPtr conn, virCHDomainObjEndJob(vm); cleanup: - if (!dom) { + if (vm && !dom) { virDomainObjListRemove(driver->domains, vm); } virDomainDefFree(vmdef);