From patchwork Thu Jan 23 20:59:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Noever X-Patchwork-Id: 3531741 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 22054C02DC for ; Thu, 23 Jan 2014 21:00:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 370F6201C0 for ; Thu, 23 Jan 2014 21:00:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4579C201BB for ; Thu, 23 Jan 2014 21:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753677AbaAWVAB (ORCPT ); Thu, 23 Jan 2014 16:00:01 -0500 Received: from mail-we0-f175.google.com ([74.125.82.175]:49799 "EHLO mail-we0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbaAWVAA (ORCPT ); Thu, 23 Jan 2014 16:00:00 -0500 Received: by mail-we0-f175.google.com with SMTP id p61so1830703wes.34 for ; Thu, 23 Jan 2014 12:59:59 -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=zpEqh3BkZmmAHYhBJ5yMJgjRsJELq4o2+Jl0c62iX5E=; b=Sor7XmyeNnww6FVnVekmEIFYKqJoVlpQ3g7qAcgmzdRNPr2HJF60jd0iaO00npN8Ls lga0ysQCBcU4AA+U8qBU7bm1YBIv1GSWQIzK038Ijz18V6enJ1fHLnBOYrNMJQApnz4u jqfbxz5l3z1D/E+BtyrZXKDQOrEBzTxwxOLY6z2AwnbOZAqX2NYtOWNwnP2i8oLFcDPe xhWAVECHKol9wAnN2yL7UKEJdiK98k8sAWU7bM0r7SDt9DsUP4UEuqlKXOe6Mu26LJNn LIejSHJIPZD45ZlXGG91bwD7pxHnk5WEsReuKisgKG+a1U+2O5qwLXAu+owHHwkUCHYG gsFQ== X-Received: by 10.180.93.169 with SMTP id cv9mr699673wib.3.1390510799369; Thu, 23 Jan 2014 12:59:59 -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.12.59.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jan 2014 12:59:58 -0800 (PST) From: Andreas Noever To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com Cc: Andreas Noever Subject: [PATCH 1/8] PCI: Increment max correctly in pci_scan_bridge. Date: Thu, 23 Jan 2014 21:59:21 +0100 Message-Id: <1390510768-5652-2-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=ham 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 This patch fixes two small issues: - If pci_add_new_bus fails then max must not be incremented. Otherwise an incorrect value is returned from pci_scan_bridge(). - If the bus is already present, then max must be incremented. I think that this case should only be hit if we trigger a manual rescan of a CardBus bridge. Signed-off-by: Andreas Noever --- drivers/pci/probe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 04796c0..78caade 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -852,11 +852,12 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) * this case we only re-scan this bus. */ child = pci_find_bus(pci_domain_nr(bus), max+1); if (!child) { - child = pci_add_new_bus(bus, dev, ++max); + child = pci_add_new_bus(bus, dev, max+1); if (!child) goto out; - pci_bus_insert_busn_res(child, max, 0xff); + pci_bus_insert_busn_res(child, max+1, 0xff); } + max++; buses = (buses & 0xff000000) | ((unsigned int)(child->primary) << 0) | ((unsigned int)(child->busn_res.start) << 8)