]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xen: Avoid possible NULL dereference
authorJohn Ferlan <jferlan@redhat.com>
Mon, 7 Jan 2013 17:09:29 +0000 (12:09 -0500)
committerEric Blake <eblake@redhat.com>
Tue, 8 Jan 2013 00:11:56 +0000 (17:11 -0700)
Change calling sequence to only call xenUnifiedDomainSetVcpusFlags() when
'dom' is not NULL. Use the GET_PRIVATE() macro to reference privateData.
Just return -1 if dom is NULL.

src/xen/xen_driver.c

index 2ef2c57adc66e0e7b169c43acbac710f27c08234..559025ec7d59602889d4c7d582a08815ab5b7ffa 100644 (file)
@@ -1253,17 +1253,17 @@ static int
 xenUnifiedDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
 {
     unsigned int flags = VIR_DOMAIN_VCPU_LIVE;
-    xenUnifiedPrivatePtr priv;
 
     /* Per the documented API, it is hypervisor-dependent whether this
      * affects just _LIVE or _LIVE|_CONFIG; in xen's case, that
      * depends on xendConfigVersion.  */
     if (dom) {
-        priv = dom->conn->privateData;
+        GET_PRIVATE(dom->conn);
         if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
             flags |= VIR_DOMAIN_VCPU_CONFIG;
+        return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags);
     }
-    return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags);
+    return -1;
 }
 
 static int