From f36d83c441048c7ba663a146dbafdce43c65186d Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Mon, 7 Jan 2013 12:09:29 -0500 Subject: [PATCH] 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. --- src/xen/xen_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- 2.47.2