From: Eduardo Habkost Date: Thu, 26 Jun 2014 21:33:19 +0000 (-0300) Subject: numa: Reject duplicate node IDs X-Git-Tag: qemu-xen-4.6.0-rc1~342^2~26 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1945b9d8b03aad59e86bfe3a3194e6bbeffbad6a;p=qemu-upstream-4.6-testing.git numa: Reject duplicate node IDs The same nodeid shouldn't appear multiple times in the command-line. In addition to detecting command-line mistakes, this will fix a bug where nb_numa_nodes may become larger than MAX_NODES (and cause out-of-bounds access on the numa_info array). Signed-off-by: Eduardo Habkost Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Hu Tao Reviewed-by: Eric Blake --- diff --git a/numa.c b/numa.c index db10f954d..c25412750 100644 --- a/numa.c +++ b/numa.c @@ -62,6 +62,11 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp) return; } + if (numa_info[nodenr].present) { + error_setg(errp, "Duplicate NUMA nodeid: %" PRIu16, nodenr); + return; + } + for (cpus = node->cpus; cpus; cpus = cpus->next) { if (cpus->value > MAX_CPUMASK_BITS) { error_setg(errp, "CPU number %" PRIu16 " is bigger than %d",