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: 9904833 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 A249A60244 for ; Thu, 17 Aug 2017 02:43:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CF6C2889E for ; Thu, 17 Aug 2017 02:43:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8103A2892C; Thu, 17 Aug 2017 02:43:00 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A2B9B288DA for ; Thu, 17 Aug 2017 02:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=48xrvdtC0HznLSiTa1BQvtQCP7bVK2ZrkmtMK628OFY=; b=bC1PYPkCvMgkgt MDUUuxHTrinob8Y4vlSdi0XnePz2rctiQMlTXWJHLeRjSWJX+GGFXA7L8+6IhdPzRZUkE+jqjaHrD ze23049CAuAbFy5Swr1jX4s11BeFmtMWm/dh/e6FgLe+INf3cRCtgCA/b9xgXaa+qG0Si7qsMGFtD yets8I3paeOVXXI9XWYFIxahfG0mvQSp1nF40Gtm07iWu8/U/7xCCQ28AQxMFo1EwhL8Nv7o835YT LS2hlrXWmtOX1iRk/WBTB9+kI69779ckfDbtygLyJULV6jXcLWSV4GOjGZOb2T/cRvL9oWoBXUpC7 o6Ro78AKOjtclcI/WAjA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1diAlN-00005Q-FG; Thu, 17 Aug 2017 02:42:25 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diAlL-0008Rf-3Q for linux-arm-kernel@bombadil.infradead.org; Thu, 17 Aug 2017 02:42:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=nYNQ/bBzUntbXxyVWs7h8IVsgS7L2GZvQsfzmZWtpgw=; b=CZM5NDjOcZwwoc2e+sBU44Tcny CnIhBLJDDMa/CuYaqt7ALmMHGRu4ppjoEVtvdu393OXf2YUoenWfGEqMdaT2JBMMOSMTY3kl817T+ PGimJRjFoYR9rRNa0n6FI+FuAiA68uk08lZlwi3RHQVCDQw8Ngos8feAEqj6yGKwPBQlq7OKswNlW G7K2GZk7v+6yS2SOVOG8xhZFzj8IVmdqBzGyo75tnluf5wJpfloLJmbrFJ4kcqG2MwyrKSgLm6Xhw GRabEnlThnqdudqMIDzgUU2CgtaNIrWU+7Q3ylxP3MStnGBO2oiqbViqIxk3lSLfgTaVoHrJ4WCiE LnzXOTpA==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diAWi-0002YV-Fg for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2017 02:27:18 +0000 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: , , , , , , , , , , , , , , , , , , , , , , , , , , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170817_032717_300414_A4E5E86F X-CRM114-Status: GOOD ( 12.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thierry Reding , Ding Tianhong Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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)) {