Blob Blame History Raw
From e8195e3a489ec211d6d637ddcdae1ca82bef3c7a Mon Sep 17 00:00:00 2001
Message-Id: <e8195e3a489ec211d6d637ddcdae1ca82bef3c7a@dist-git>
From: Martin Kletzander <mkletzan@redhat.com>
Date: Wed, 24 Aug 2016 16:10:58 -0400
Subject: [PATCH] conf: Make really sure we don't access non-existing vCPUs

https://bugzilla.redhat.com/show_bug.cgi?id=1097930
https://bugzilla.redhat.com/show_bug.cgi?id=1224341

MinGW complained that we might be dereferencing a NULL pointer.  While
that can't be true, the logic certainly allows for that.

src/conf/domain_conf.c: In function 'virDomainDefGetVcpuPinInfoHelper':
src/conf/domain_conf.c:1545:17: error: potential null pointer dereference [-Werror=null-dereference]
         if (vcpu->cpumask)
              ~~~~^~~~~~~~~

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit a6ab72a9c3ad475a544ffd53a782e46a02437006)
---
 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 384059d..7fa4701 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1544,7 +1544,7 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
         virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i);
         virBitmapPtr bitmap = NULL;
 
-        if (vcpu->cpumask)
+        if (vcpu && vcpu->cpumask)
             bitmap = vcpu->cpumask;
         else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
                  autoCpuset)
-- 
2.10.0