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.
This commit is contained in:
John Ferlan 2013-01-07 12:09:29 -05:00 committed by Eric Blake
parent 4f1f9d91ab
commit f36d83c441

View 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