]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
numa: Reject duplicate node IDs
authorEduardo Habkost <ehabkost@redhat.com>
Thu, 26 Jun 2014 21:33:19 +0000 (18:33 -0300)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 29 Jun 2014 15:59:42 +0000 (18:59 +0300)
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 <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
numa.c

diff --git a/numa.c b/numa.c
index db10f954dd534903d4ebf532d610a6ac33f366a2..c25412750414d484b155a150f37188fd3fffb405 100644 (file)
--- 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",