[PATCH 9/9] ch_driver: Handle validation failure correctly

William Douglas william.douglas at intel.com
Wed Sep 8 18:01:23 UTC 2021


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.

Signed-off-by: William Douglas <william.douglas at intel.com>
---
 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);
-- 
2.31.1




More information about the libvir-list mailing list