[libvirt] [PATCH] xen: Resolve Coverity FORWARD_NULL issue

John Ferlan jferlan at redhat.com
Thu May 23 15:20:57 UTC 2013


Commit '18b14012' refactored the Xen code resulting in a Coverity
warning about possible NULL reference if the path where the XM driver
takes puts the def on it's list.  Moved/duplicated the virGetDomain()
call to pacify the possible NULL deref.

NOTE: I did ping Dan B, but he is away, so rather than wait or take
the chance this ends up in the upcoming release, I made the change.

---
 src/xen/xen_driver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index cc6e486..9eab3fc 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1658,13 +1658,14 @@ xenUnifiedDomainDefineXML(virConnectPtr conn, const char *xml)
     if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
         if (xenXMDomainDefineXML(conn, def) < 0)
             goto cleanup;
+        ret = virGetDomain(conn, def->name, def->uuid);
         def = NULL; /* XM driver owns it now */
     } else {
         if (xenDaemonDomainDefineXML(conn, def) < 0)
             goto cleanup;
+        ret = virGetDomain(conn, def->name, def->uuid);
     }
 
-    ret = virGetDomain(conn, def->name, def->uuid);
     if (ret)
         ret->id = -1;
 
-- 
1.8.1.4




More information about the libvir-list mailing list