* [PATCH] PCI: rcar-pcie: Fix memory leak when no PCIe card is inserted @ 2017-08-02 7:13 Harunobu Kurokawa 2017-08-02 9:03 ` Lorenzo Pieralisi 0 siblings, 1 reply; 3+ messages in thread From: Harunobu Kurokawa @ 2017-08-02 7:13 UTC (permalink / raw) To: horms, bhelgaas, linux-pci Cc: linux-renesas-soc, linux-kernel, Harunobu Kurokawa When no PCIe card is inserted, there is a memory leak as pci_free_resource_list is not called before returning. Signed-off-by: Harunobu Kurokawa <harunobu.kurokawa.dn@renesas.com> --- drivers/pci/host/pcie-rcar.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index ac80fbb..9b06de6 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -1190,14 +1190,15 @@ static int rcar_pcie_probe(struct platform_device *pdev) return 0; -err_free_bridge: - pci_free_host_bridge(bridge); - err_pm_put: pm_runtime_put(dev); err_pm_disable: pm_runtime_disable(dev); + +err_free_bridge: + pci_free_host_bridge(bridge); + pci_free_resource_list(&pcie->resources); return err; } -- 2.9.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: rcar-pcie: Fix memory leak when no PCIe card is inserted 2017-08-02 7:13 [PATCH] PCI: rcar-pcie: Fix memory leak when no PCIe card is inserted Harunobu Kurokawa @ 2017-08-02 9:03 ` Lorenzo Pieralisi 2017-08-03 5:07 ` HARUNOBU KUROKAWA 0 siblings, 1 reply; 3+ messages in thread From: Lorenzo Pieralisi @ 2017-08-02 9:03 UTC (permalink / raw) To: Harunobu Kurokawa Cc: horms, bhelgaas, linux-pci, linux-renesas-soc, linux-kernel On Wed, Aug 02, 2017 at 04:13:20PM +0900, Harunobu Kurokawa wrote: > When no PCIe card is inserted, there is a memory leak as > pci_free_resource_list is not called before returning. > > Signed-off-by: Harunobu Kurokawa <harunobu.kurokawa.dn@renesas.com> > --- > drivers/pci/host/pcie-rcar.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c > index ac80fbb..9b06de6 100644 > --- a/drivers/pci/host/pcie-rcar.c > +++ b/drivers/pci/host/pcie-rcar.c > @@ -1190,14 +1190,15 @@ static int rcar_pcie_probe(struct platform_device *pdev) > > return 0; > > -err_free_bridge: > - pci_free_host_bridge(bridge); > - > err_pm_put: > pm_runtime_put(dev); > > err_pm_disable: > pm_runtime_disable(dev); > + > +err_free_bridge: > + pci_free_host_bridge(bridge); > + pci_free_resource_list(&pcie->resources); > return err; > } The error code path needs fixing but not like this (with a single patch lumping all fixes - well, actually it does not - together). Step one, patch below. Step two free the &pci->resources list (which IIUC was not freed even before commit 90634e854079) in a separate patch. Am I missing something ? Please apply, check and repost the patch if it is ok, thanks. -- >8 -- Subject: [PATCH] PCI: rcar: Fix error exit path Commit 90634e854079 ("PCI: rcar: Convert PCI scan API to pci_scan_root_bus_bridge()") converted PCI root bus scan API to the new pci_scan_root_bus_bridge() API; in the process some error paths were not updated correctly which may cause memory leaks. Fix the driver error exit path reinstating the previous correct error exit behaviour. Fixes: 90634e854079 ("PCI: rcar: Convert PCI scan API to pci_scan_root_bus_bridge()") Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> --- drivers/pci/host/pcie-rcar.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 246d485..007523e 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -471,10 +471,8 @@ static int rcar_pcie_enable(struct rcar_pcie *pcie) bridge->msi = &pcie->msi.chip; ret = pci_scan_root_bus_bridge(bridge); - if (ret < 0) { - kfree(bridge); + if (ret < 0) return ret; - } bus = bridge->bus; @@ -1190,14 +1188,15 @@ static int rcar_pcie_probe(struct platform_device *pdev) return 0; -err_free_bridge: - pci_free_host_bridge(bridge); - err_pm_put: pm_runtime_put(dev); err_pm_disable: pm_runtime_disable(dev); + +err_free_bridge: + pci_free_host_bridge(bridge); + return err; } -- 2.10.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] PCI: rcar-pcie: Fix memory leak when no PCIe card is inserted 2017-08-02 9:03 ` Lorenzo Pieralisi @ 2017-08-03 5:07 ` HARUNOBU KUROKAWA 0 siblings, 0 replies; 3+ messages in thread From: HARUNOBU KUROKAWA @ 2017-08-03 5:07 UTC (permalink / raw) To: Lorenzo Pieralisi Cc: horms@verge.net.au, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Hi=20 > -----Original Message----- > From: Lorenzo Pieralisi [mailto:lorenzo.pieralisi@arm.com] > Sent: Wednesday, August 2, 2017 6:03 PM > To: HARUNOBU KUROKAWA <harunobu.kurokawa.dn@renesas.com> > Cc: horms@verge.net.au; bhelgaas@google.com; linux-pci@vger.kernel.org; l= inux-renesas-soc@vger.kernel.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH] PCI: rcar-pcie: Fix memory leak when no PCIe card is= inserted >=20 > On Wed, Aug 02, 2017 at 04:13:20PM +0900, Harunobu Kurokawa wrote: > > When no PCIe card is inserted, there is a memory leak as > > pci_free_resource_list is not called before returning. > > > > Signed-off-by: Harunobu Kurokawa <harunobu.kurokawa.dn@renesas.com> > > --- > > drivers/pci/host/pcie-rcar.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/pci/host/pcie-rcar.c > > b/drivers/pci/host/pcie-rcar.c index ac80fbb..9b06de6 100644 > > --- a/drivers/pci/host/pcie-rcar.c > > +++ b/drivers/pci/host/pcie-rcar.c > > @@ -1190,14 +1190,15 @@ static int rcar_pcie_probe(struct > > platform_device *pdev) > > > > return 0; > > > > -err_free_bridge: > > - pci_free_host_bridge(bridge); > > - > > err_pm_put: > > pm_runtime_put(dev); > > > > err_pm_disable: > > pm_runtime_disable(dev); > > + > > +err_free_bridge: > > + pci_free_host_bridge(bridge); > > + pci_free_resource_list(&pcie->resources); > > return err; > > } >=20 > The error code path needs fixing but not like this (with a single patch l= umping all fixes - well, actually it does not - together). >=20 > Step one, patch below. Step two free the &pci->resources list (which IIUC= was not freed even before commit 90634e854079) in a separate > patch. >=20 > Am I missing something ? >=20 > Please apply, check and repost the patch if it is ok, thanks. Yes, I'll sprit the patch and repost them. Best regards, Kurokawa. >=20 > -- >8 -- > Subject: [PATCH] PCI: rcar: Fix error exit path >=20 > Commit 90634e854079 ("PCI: rcar: Convert PCI scan API to > pci_scan_root_bus_bridge()") converted PCI root bus scan API to the new p= ci_scan_root_bus_bridge() API; in the process some error > paths were not updated correctly which may cause memory leaks. >=20 > Fix the driver error exit path reinstating the previous correct error exi= t behaviour. >=20 > Fixes: 90634e854079 ("PCI: rcar: Convert PCI scan API to pci_scan_root_bu= s_bridge()") > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> > --- > drivers/pci/host/pcie-rcar.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c = index 246d485..007523e 100644 > --- a/drivers/pci/host/pcie-rcar.c > +++ b/drivers/pci/host/pcie-rcar.c > @@ -471,10 +471,8 @@ static int rcar_pcie_enable(struct rcar_pcie *pcie) > bridge->msi =3D &pcie->msi.chip; >=20 > ret =3D pci_scan_root_bus_bridge(bridge); > - if (ret < 0) { > - kfree(bridge); > + if (ret < 0) > return ret; > - } >=20 > bus =3D bridge->bus; >=20 > @@ -1190,14 +1188,15 @@ static int rcar_pcie_probe(struct platform_device= *pdev) >=20 > return 0; >=20 > -err_free_bridge: > - pci_free_host_bridge(bridge); > - > err_pm_put: > pm_runtime_put(dev); >=20 > err_pm_disable: > pm_runtime_disable(dev); > + > +err_free_bridge: > + pci_free_host_bridge(bridge); > + > return err; > } >=20 > -- > 2.10.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-03 5:07 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-08-02 7:13 [PATCH] PCI: rcar-pcie: Fix memory leak when no PCIe card is inserted Harunobu Kurokawa 2017-08-02 9:03 ` Lorenzo Pieralisi 2017-08-03 5:07 ` HARUNOBU KUROKAWA
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).