From patchwork Mon Dec 7 21:32:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 7791221 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9F0D09F1C2 for ; Mon, 7 Dec 2015 21:34:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA771202F2 for ; Mon, 7 Dec 2015 21:34:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 005C2203B4 for ; Mon, 7 Dec 2015 21:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932938AbbLGVdq (ORCPT ); Mon, 7 Dec 2015 16:33:46 -0500 Received: from mga01.intel.com ([192.55.52.88]:4465 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933373AbbLGVch (ORCPT ); Mon, 7 Dec 2015 16:32:37 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 07 Dec 2015 13:32:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,396,1444719600"; d="scan'208";a="866649093" Received: from dcgshare.lm.intel.com ([10.232.118.254]) by orsmga002.jf.intel.com with ESMTP; 07 Dec 2015 13:32:35 -0800 Received: by dcgshare.lm.intel.com (Postfix, from userid 1017) id 34B11E0C67; Mon, 7 Dec 2015 14:32:35 -0700 (MST) From: Keith Busch To: LKML , x86@kernel.org, linux-pci@vger.kernel.org Cc: Jiang Liu , Thomas Gleixner , Dan Williams , Bjorn Helgaas , Bryan Veal , Ingo Molnar , "H. Peter Anvin" , Martin Mares , Jon Derrick , Keith Busch Subject: [PATCHv6 2/7] pci: child bus alloc fix on constrained resource Date: Mon, 7 Dec 2015 14:32:24 -0700 Message-Id: <1449523949-21898-3-git-send-email-keith.busch@intel.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1449523949-21898-1-git-send-email-keith.busch@intel.com> References: <1449523949-21898-1-git-send-email-keith.busch@intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Does not allocate a child bus if the new bus number does not fit in the parent's bus resource window. Signed-off-by: Keith Busch --- drivers/pci/probe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index edb1984..6e29f7a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -704,6 +704,12 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, int i; int ret; + if (busnr > parent->busn_res.end) { + dev_printk(KERN_DEBUG, &parent->dev, + "can not alloc bus:%d under %pR\n", busnr, + &parent->busn_res); + return NULL; + } /* * Allocate a new bus, and inherit stuff from the parent.. */