From: John Ferlan Date: Mon, 7 Jan 2013 17:09:29 +0000 (-0500) Subject: xen: Avoid possible NULL dereference X-Git-Tag: v1.0.2-rc1~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f36d83c441048c7ba663a146dbafdce43c65186d;p=thirdparty%2Flibvirt.git xen: Avoid possible NULL dereference 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. --- diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 2ef2c57adc..559025ec7d 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -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