]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ch_driver: Handle validation failure correctly
authorWilliam Douglas <william.douglas@intel.com>
Wed, 8 Sep 2021 18:01:23 +0000 (11:01 -0700)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 9 Sep 2021 13:51:02 +0000 (14:51 +0100)
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>
src/ch/ch_driver.c

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