From patchwork Sun Jun 29 16:58:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 365413 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1F8871400A0 for ; Mon, 30 Jun 2014 03:03:58 +1000 (EST) Received: from localhost ([::1]:58409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1IWB-0005p9-LO for incoming@patchwork.ozlabs.org; Sun, 29 Jun 2014 13:03:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1IQr-0006gH-6z for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:58:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1IQm-0003D2-Iy for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:58:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1IQm-0003Cy-Bh for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:58:20 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5TGwGEM004757 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jun 2014 12:58:16 -0400 Received: from redhat.com (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id s5TGwCe5018681; Sun, 29 Jun 2014 12:58:13 -0400 Date: Sun, 29 Jun 2014 19:58:40 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1404060115-27410-12-git-send-email-mst@redhat.com> References: <1404060115-27410-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1404060115-27410-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Eduardo Habkost , Hu Tao , Anthony Liguori , Paolo Bonzini , Wanlong Gao Subject: [Qemu-devel] [PULL 11/37] numa: Reject duplicate node IDs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Eduardo Habkost 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 --- numa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/numa.c b/numa.c index db10f95..c254127 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",