Received: from eggs.gnu.org ([2001:4830:134:3::10]:45189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0HIc-0002yI-CA for qemu-devel@nongnu.org; Thu, 26 Jun 2014 17:33:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0HIW-0007sw-3R for qemu-devel@nongnu.org; Thu, 26 Jun 2014 17:33:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0HIV-0007si-SV for qemu-devel@nongnu.org; Thu, 26 Jun 2014 17:33:36 -0400 From: Eduardo Habkost Date: Thu, 26 Jun 2014 18:33:19 -0300 Message-Id: <1403818400-13671-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1403818400-13671-1-git-send-email-ehabkost@redhat.com> References: <1403818400-13671-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] numa: Reject duplicate node IDs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Hu Tao Cc: "Michael S. Tsirkin" , Alexey Kardashevskiy , Nishanth Aravamudan , Anton Blanchard , David Rientjes , Igor Mammedov 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 --- numa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/numa.c b/numa.c index 3de9116..e93407a 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", -- 1.9.3