virDomainNumaGetNodeDistance: Fix input arguments validation

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>
This commit is contained in:
Michal Privoznik 2017-11-14 14:24:20 +01:00
parent 96f7a045e9
commit 0ededbb84e

View File

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