From patchwork Thu Jun 25 02:01:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 32288 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5P21sJ1002275 for ; Thu, 25 Jun 2009 02:01:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754142AbZFYCBr (ORCPT ); Wed, 24 Jun 2009 22:01:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753173AbZFYCBr (ORCPT ); Wed, 24 Jun 2009 22:01:47 -0400 Received: from hera.kernel.org ([140.211.167.34]:43539 "EHLO hera.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752609AbZFYCBq (ORCPT ); Wed, 24 Jun 2009 22:01:46 -0400 Received: from [192.168.86.129] (70.89.117.125-Busname-WA.hfc.comcastbusiness.net [70.89.117.125]) (authenticated bits=0) by hera.kernel.org (8.14.2/8.13.8) with ESMTP id n5P21LNm000331 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Jun 2009 02:01:25 GMT Message-ID: <4A42DA6F.2030305@kernel.org> Date: Wed, 24 Jun 2009 19:01:19 -0700 From: Yinghai Lu User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: Ingo Molnar , Jesse Barnes , Gary Hade , Matthew Wilcox , "H. Peter Anvin" , Linus Torvalds , Thomas Gleixner , Suresh Siddha CC: Andrew Morton , linux-pci@vger.kernel.org, "linux-kernel@vger.kernel.org" Subject: [PATCH 1/3] x86/pci: fix boundary checking when using root CRS References: <20090624122433.GA24781@elte.hu> <20090624145119.GA12664@elte.hu> <4A429EBB.5010209@kernel.org> In-Reply-To: <4A429EBB.5010209@kernel.org> X-Virus-Scanned: ClamAV 0.93.3/9505/Wed Jun 24 22:47:21 2009 on hera.kernel.org X-Virus-Status: Clean Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org don't touch info->res_num if we are out of space Signed-off-by: Yinghai Lu --- arch/x86/pci/acpi.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/arch/x86/pci/acpi.c =================================================================== --- linux-2.6.orig/arch/x86/pci/acpi.c +++ linux-2.6/arch/x86/pci/acpi.c @@ -68,6 +68,10 @@ setup_resource(struct acpi_resource *acp unsigned long flags; struct resource *root; int max_root_bus_resources = PCI_BUS_NUM_RESOURCES; + u64 start, end; + + if (bus_has_transparent_bridge(info->bus)) + max_root_bus_resources -= 3; status = resource_to_addr(acpi_res, &addr); if (!ACPI_SUCCESS(status)) @@ -84,25 +88,24 @@ setup_resource(struct acpi_resource *acp } else return AE_OK; - res = &info->res[info->res_num]; - res->name = info->name; - res->flags = flags; - res->start = addr.minimum + addr.translation_offset; - res->end = res->start + addr.address_length - 1; - res->child = NULL; - - if (bus_has_transparent_bridge(info->bus)) - max_root_bus_resources -= 3; + start = addr.minimum + addr.translation_offset; + end = start + addr.address_length - 1; if (info->res_num >= max_root_bus_resources) { printk(KERN_WARNING "PCI: Failed to allocate 0x%lx-0x%lx " "from %s for %s due to _CRS returning more than " - "%d resource descriptors\n", (unsigned long) res->start, - (unsigned long) res->end, root->name, info->name, + "%d resource descriptors\n", (unsigned long) start, + (unsigned long) end, root->name, info->name, max_root_bus_resources); - info->res_num++; return AE_OK; } + res = &info->res[info->res_num]; + res->name = info->name; + res->flags = flags; + res->start = start; + res->end = end; + res->child = NULL; + if (insert_resource(root, res)) { printk(KERN_ERR "PCI: Failed to allocate 0x%lx-0x%lx " "from %s for %s\n", (unsigned long) res->start,