From patchwork Tue Nov 29 06:21:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 128220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0B0271007D2 for ; Tue, 29 Nov 2011 17:22:02 +1100 (EST) Received: from localhost ([::1]:50864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVH4k-0002O6-2O for incoming@patchwork.ozlabs.org; Tue, 29 Nov 2011 01:21:54 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVH4d-0002O0-4h for qemu-devel@nongnu.org; Tue, 29 Nov 2011 01:21:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RVH4c-0003fR-7M for qemu-devel@nongnu.org; Tue, 29 Nov 2011 01:21:47 -0500 Received: from ozlabs.org ([203.10.76.45]:36137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RVH4b-0003f1-RS; Tue, 29 Nov 2011 01:21:46 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id C38E91007D2; Tue, 29 Nov 2011 17:21:42 +1100 (EST) From: David Gibson To: agraf@suse.de Date: Tue, 29 Nov 2011 17:21:39 +1100 Message-Id: <1322547699-28329-1-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 1.7.7.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: aik@ozlabs.ru, sw@weilnetz.de, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] pseries: Fix array overrun bug in PCI code 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 spapr_populate_pci_devices() containd a loop with PCI_NUM_REGIONS (7) iterations. However this overruns the 'bars' global array, which only has 6 elements. In fact we only want to run this loop for things listed in the bars array, so this patch corrects the loop bounds to reflect that. Signed-off-by: David Gibson --- hw/spapr_pci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c index 7162588..9b6a032 100644 --- a/hw/spapr_pci.c +++ b/hw/spapr_pci.c @@ -454,7 +454,7 @@ int spapr_populate_pci_devices(sPAPRPHBState *phb, reg[0].size = 0; n = 0; - for (i = 0; i < PCI_NUM_REGIONS; ++i) { + for (i = 0; i < ARRAY_SIZE(bars); ++i) { if (0 == dev->io_regions[i].size) { continue; }