From patchwork Thu Jan 23 20:59:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Noever X-Patchwork-Id: 3531801 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7B5E79F39B for ; Thu, 23 Jan 2014 21:00:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B25D9201BC for ; Thu, 23 Jan 2014 21:00:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42720201C7 for ; Thu, 23 Jan 2014 21:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754379AbaAWVAH (ORCPT ); Thu, 23 Jan 2014 16:00:07 -0500 Received: from mail-wg0-f51.google.com ([74.125.82.51]:47413 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbaAWVAF (ORCPT ); Thu, 23 Jan 2014 16:00:05 -0500 Received: by mail-wg0-f51.google.com with SMTP id z12so2162610wgg.30 for ; Thu, 23 Jan 2014 13:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TFFRVyBOhjmps8QbDRlbalHYs/820TcDvobe69KpyA0=; b=hs4RSaO6xqutMS4eQzc1ccCVjt3Jm1nyNVmO2O2+J8WFije/VmuZ7+RxhRUt/+5o5w Qii6NvgwjkGONx6bx3P2kOidF5L2pm6OAEMbEX5m3v6dmwoASGaITnRvShffXxbuBoot irS1xF1obWArlvXVu3lWdWqsmj4GjABM/rUoOF9y29nILcJm48+7qa/LavdIpOCV+/bV 58fB+XArxkY7l6/vkqdyRHxTuC4paJzuQMFebBnxrai5VUDpg3H+CHvQWYgjQ17jzA6b q4L/aY2nIL0wGszua1+n1b79JLXG3Q345z0aIcp8iE8oX6zkKQ+qU/A0WPZwWBEqpUrY pWlw== X-Received: by 10.194.109.68 with SMTP id hq4mr8306265wjb.12.1390510804244; Thu, 23 Jan 2014 13:00:04 -0800 (PST) Received: from localhost.localdomain (77-58-151-250.dclient.hispeed.ch. [77.58.151.250]) by mx.google.com with ESMTPSA id ux5sm25371408wjc.6.2014.01.23.13.00.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jan 2014 13:00:03 -0800 (PST) From: Andreas Noever To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com Cc: Andreas Noever Subject: [PATCH 7/8] PCI: Check for child busses which use more bus numbers than allocated. Date: Thu, 23 Jan 2014 21:59:27 +0100 Message-Id: <1390510768-5652-8-git-send-email-andreas.noever@gmail.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1390510768-5652-1-git-send-email-andreas.noever@gmail.com> References: <1390510768-5652-1-git-send-email-andreas.noever@gmail.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=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 pci_scan_child_bus can (potentially) return a bus number higher than the subordinate value of the child bus. Possible reasons are that bus numbers are reserved for SR-IOV or for CardBus (SR-IOV is done without checks and the CardBus checks are sketchy at best). We clamp the returned value to the actual subordinate value and print a warning if too many bus numbers are reserved. Signed-off-by: Andreas Noever --- drivers/pci/probe.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 90d5c48..74bc644 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -805,10 +805,13 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) } cmax = pci_scan_child_bus(child); - if (cmax > max) - max = cmax; - if (child->busn_res.end > max) - max = child->busn_res.end; + if (cmax > subordinate) + dev_warn(&dev->dev, + "bridge has subordinate %02x but max busn %02x\n", + subordinate, cmax); + /* subordinate should equal child->busn_res.end */ + if (subordinate > max) + max = subordinate; } else { /* * We need to assign a number to this bus which we always