From patchwork Tue Aug 19 07:18:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 381257 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 D521C140095 for ; Tue, 19 Aug 2014 17:21:09 +1000 (EST) Received: from localhost ([::1]:48544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJdjA-0007gY-0a for incoming@patchwork.ozlabs.org; Tue, 19 Aug 2014 03:21:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJdip-0007Pm-Ow for qemu-devel@nongnu.org; Tue, 19 Aug 2014 03:20:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJdik-0005Yu-Tx for qemu-devel@nongnu.org; Tue, 19 Aug 2014 03:20:47 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:39475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJdik-0005Ya-0p for qemu-devel@nongnu.org; Tue, 19 Aug 2014 03:20:42 -0400 Received: from 172.24.2.119 (EHLO szxeml406-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BYJ07032; Tue, 19 Aug 2014 15:19:05 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml406-hub.china.huawei.com (10.82.67.93) with Microsoft SMTP Server id 14.3.158.1; Tue, 19 Aug 2014 15:18:58 +0800 From: To: Date: Tue, 19 Aug 2014 15:18:44 +0800 Message-ID: <1408432724-15676-1-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: Gonglei , weidong.huang@huawei.com, mst@redhat.com Subject: [Qemu-devel] [PATCH] pcihp: fix possible array out of bounds 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: Gonglei When 'bsel == ACPI_PCIHP_MAX_HOTPLUG_BUS', the s->acpi_pcihp_pci_status[bsel] array will out of bounds. Add check for this. Signed-off-by: Gonglei Reviewed-by: Peter Crosthwaite --- hw/acpi/pcihp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index fae663a..34dedf1 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }