render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c1c534
From 1033a81438d6eae6eea225d489f876749f966f4d Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <1033a81438d6eae6eea225d489f876749f966f4d@dist-git>
c1c534
From: Michal Privoznik <mprivozn@redhat.com>
c1c534
Date: Mon, 4 Dec 2017 13:38:49 +0100
c1c534
Subject: [PATCH] virDomainNumaGetNodeDistance: Fix input arguments validation
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1454889
c1c534
c1c534
There's no point in checking if numa->mem_nodes[node].ndistances
c1c534
is set if we check for numa->mem_nodes[node].distances. However,
c1c534
it makes sense to check if the sibling node (@cellid) caller
c1c534
passed falls within boundaries.
c1c534
c1c534
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c1c534
Reviewed-by: John Ferlan <jferlan@redhat.com>
c1c534
(cherry picked from commit 0ededbb84eb34539e326b4d4791772b699352302)
c1c534
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/conf/numa_conf.c | 4 ++--
c1c534
 1 file changed, 2 insertions(+), 2 deletions(-)
c1c534
c1c534
diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
c1c534
index 7bba4120bd..c2f0d1ca8c 100644
c1c534
--- a/src/conf/numa_conf.c
c1c534
+++ b/src/conf/numa_conf.c
c1c534
@@ -1153,8 +1153,8 @@ virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
c1c534
      * defined default for local and remote nodes.
c1c534
      */
c1c534
     if (!distances ||
c1c534
-        !distances[cellid].value ||
c1c534
-        !numa->mem_nodes[node].ndistances)
c1c534
+        cellid >= numa->nmem_nodes ||
c1c534
+        !distances[cellid].value)
c1c534
         return (node == cellid) ? LOCAL_DISTANCE : REMOTE_DISTANCE;
c1c534
 
c1c534
     return distances[cellid].value;
c1c534
-- 
c1c534
2.15.1
c1c534