]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainNumaGetNodeDistance: Fix input arguments validation
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 14 Nov 2017 13:24:20 +0000 (14:24 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 23 Nov 2017 13:54:31 +0000 (14:54 +0100)
There's no point in checking if numa->mem_nodes[node].ndistances
is set if we check for numa->mem_nodes[node].distances. However,
it makes sense to check if the sibling node (@cellid) caller
passed falls within boundaries.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/conf/numa_conf.c

index 7bba4120bd6a9de3599d21e87093e7632284d5fb..c2f0d1ca8ca66aa9712b02ff055c3e1b00739ef8 100644 (file)
@@ -1153,8 +1153,8 @@ virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
      * defined default for local and remote nodes.
      */
     if (!distances ||
-        !distances[cellid].value ||
-        !numa->mem_nodes[node].ndistances)
+        cellid >= numa->nmem_nodes ||
+        !distances[cellid].value)
         return (node == cellid) ? LOCAL_DISTANCE : REMOTE_DISTANCE;
 
     return distances[cellid].value;