From c88b26a656a48a976300b4f0e1745058307f5a89 Mon Sep 17 00:00:00 2001 From: William Douglas Date: Wed, 8 Sep 2021 11:01:23 -0700 Subject: [PATCH] ch_driver: Handle validation failure correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/ch/ch_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);