From patchwork Mon Jul 10 12:34:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 9832861 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 045BC60393 for ; Mon, 10 Jul 2017 12:32:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB7AF27F2B for ; Mon, 10 Jul 2017 12:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0243282EC; Mon, 10 Jul 2017 12:32:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E4CC27F2B for ; Mon, 10 Jul 2017 12:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753974AbdGJMch (ORCPT ); Mon, 10 Jul 2017 08:32:37 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35052 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753927AbdGJMcg (ORCPT ); Mon, 10 Jul 2017 08:32:36 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1BE55344; Mon, 10 Jul 2017 05:32:36 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.206.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1749E3F7BA; Mon, 10 Jul 2017 05:32:34 -0700 (PDT) From: Lorenzo Pieralisi To: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lorenzo Pieralisi , Ralf Baechle , Paul Burton , Bjorn Helgaas Subject: [PATCH 2/2] MIPS/PCI: Fix pcibios_scan_bus() NULL check code path Date: Mon, 10 Jul 2017 13:34:09 +0100 Message-Id: <20170710123409.9043-2-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170710123409.9043-1-lorenzo.pieralisi@arm.com> References: <20170710123409.9043-1-lorenzo.pieralisi@arm.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If pci_scan_root_bus() fails (ie returns NULL) pcibios_scan_bus() must return immediately since the struct pci_bus pointer it returns is not valid and cannot be used. Move code checking the pci_scan_root_bus() return value to reinstate proper pcibios_scanbus() error path behaviour. Signed-off-by: Lorenzo Pieralisi Cc: Ralf Baechle Cc: Paul Burton Cc: Bjorn Helgaas --- arch/mips/pci/pci-legacy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c index 174575a..71d62f8 100644 --- a/arch/mips/pci/pci-legacy.c +++ b/arch/mips/pci/pci-legacy.c @@ -89,16 +89,16 @@ static void pcibios_scanbus(struct pci_controller *hose) pci_add_resource(&resources, hose->busn_resource); bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, &resources); - hose->bus = bus; - - need_domain_info = need_domain_info || pci_domain_nr(bus); - set_pci_need_domain_info(hose, need_domain_info); - if (!bus) { pci_free_resource_list(&resources); return; } + hose->bus = bus; + + need_domain_info = need_domain_info || pci_domain_nr(bus); + set_pci_need_domain_info(hose, need_domain_info); + next_busno = bus->busn_res.end + 1; /* Don't allow 8-bit bus number overflow inside the hose - reserve some space for bridges. */