Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752363AbdHQMlk (ORCPT ); Thu, 17 Aug 2017 08:41:40 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4479 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561AbdHQMlj (ORCPT ); Thu, 17 Aug 2017 08:41:39 -0400 Subject: Re: [PATCH net] PCI: fix the return value for the pci_find_pcie_root_port() To: Thierry Reding References: <1502936730-7368-1-git-send-email-dingtianhong@huawei.com> <20170817105156.GA18789@ulmo> CC: , , , , , , , , , , , , , , , , , , , , , , , , , , From: Ding Tianhong Message-ID: Date: Thu, 17 Aug 2017 20:40:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170817105156.GA18789@ulmo> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.23.32] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0207.59958EC1.0145,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: 86d3460152d4c75068d464a493cbd897 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1830 Lines: 50 On 2017/8/17 18:51, Thierry Reding wrote: > On Thu, Aug 17, 2017 at 10:25:30AM +0800, Ding Tianhong wrote: >> 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)) { > > I think this should actually be this change on top of a revert of commit > 0e405232871d6 ("PCI: fix oops when try to find Root Port for a PCI > device"). After the above change, the previous fix will have a redundant > check because highest_pcie_bridge will never be NULL. > > Let me send out that version to clarify what I mean. > Hi Thierry: The patch ("PCI: fix oops when try to find Root Port for a PCI device") has been merge to the linus mainline tree before you found this deficiencies.... Regards Tianhong > Thierry >