From patchwork Thu Aug 17 02:25:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 9904827 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 99CB260231 for ; Thu, 17 Aug 2017 02:26:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 856AB28995 for ; Thu, 17 Aug 2017 02:26:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A124289D9; Thu, 17 Aug 2017 02:26:31 +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=unavailable 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 F363D28995 for ; Thu, 17 Aug 2017 02:26:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752294AbdHQC0P (ORCPT ); Wed, 16 Aug 2017 22:26:15 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3574 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751943AbdHQC0N (ORCPT ); Wed, 16 Aug 2017 22:26:13 -0400 Received: from 172.30.72.60 (EHLO DGGEMS407-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFK11069; Thu, 17 Aug 2017 10:25:54 +0800 (CST) Received: from localhost (10.177.23.32) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.301.0; Thu, 17 Aug 2017 10:25:41 +0800 From: Ding Tianhong To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Ding Tianhong , Thierry Reding Subject: [PATCH net] PCI: fix the return value for the pci_find_pcie_root_port() Date: Thu, 17 Aug 2017 10:25:30 +0800 Message-ID: <1502936730-7368-1-git-send-email-dingtianhong@huawei.com> X-Mailer: git-send-email 1.8.5.2.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.23.32] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.5994FEB3.01A2, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: db37463305566693fad6b0653276d232 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 The pci_find_pcie_root_port() would return NULL if the given dev is already a Root Port, it looks like unfriendly to the PCIe Root Port device, Thierry and Bjorn suggest to let this function return the given dev under this circumstances. Fixes: 0e405232871d6 ("PCI: fix oops when try to find Root Port for a PCI device") Suggested-by: Thierry Reding Suggested-by: Bjorn Helgaas Signed-off-by: Thierry Reding Signed-off-by: Ding Tianhong --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7e2022f..352bb53 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -514,7 +514,7 @@ struct resource *pci_find_resource(struct pci_dev *dev, struct resource *res) */ struct pci_dev *pci_find_pcie_root_port(struct pci_dev *dev) { - struct pci_dev *bridge, *highest_pcie_bridge = NULL; + struct pci_dev *bridge, *highest_pcie_bridge = dev; bridge = pci_upstream_bridge(dev); while (bridge && pci_is_pcie(bridge)) {