render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
6ae9ed
From e8195e3a489ec211d6d637ddcdae1ca82bef3c7a Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <e8195e3a489ec211d6d637ddcdae1ca82bef3c7a@dist-git>
6ae9ed
From: Martin Kletzander <mkletzan@redhat.com>
6ae9ed
Date: Wed, 24 Aug 2016 16:10:58 -0400
6ae9ed
Subject: [PATCH] conf: Make really sure we don't access non-existing vCPUs
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
6ae9ed
6ae9ed
MinGW complained that we might be dereferencing a NULL pointer.  While
6ae9ed
that can't be true, the logic certainly allows for that.
6ae9ed
6ae9ed
src/conf/domain_conf.c: In function 'virDomainDefGetVcpuPinInfoHelper':
6ae9ed
src/conf/domain_conf.c:1545:17: error: potential null pointer dereference [-Werror=null-dereference]
6ae9ed
         if (vcpu->cpumask)
6ae9ed
              ~~~~^~~~~~~~~
6ae9ed
6ae9ed
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
6ae9ed
(cherry picked from commit a6ab72a9c3ad475a544ffd53a782e46a02437006)
6ae9ed
---
6ae9ed
 src/conf/domain_conf.c | 2 +-
6ae9ed
 1 file changed, 1 insertion(+), 1 deletion(-)
6ae9ed
6ae9ed
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
6ae9ed
index 384059d..7fa4701 100644
6ae9ed
--- a/src/conf/domain_conf.c
6ae9ed
+++ b/src/conf/domain_conf.c
6ae9ed
@@ -1544,7 +1544,7 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
6ae9ed
         virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i);
6ae9ed
         virBitmapPtr bitmap = NULL;
6ae9ed
 
6ae9ed
-        if (vcpu->cpumask)
6ae9ed
+        if (vcpu && vcpu->cpumask)
6ae9ed
             bitmap = vcpu->cpumask;
6ae9ed
         else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
6ae9ed
                  autoCpuset)
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed