Message ID | 55b11e9a7fa2987fbc0869d68ae59888954d65e2.1620148539.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Lorenzo Pieralisi |
Headers | show |
Series | [1/3] PCI: tegra: Fix OF node reference leak | expand |
On Tue, May 04, 2021 at 07:17:42PM +0200, Christophe JAILLET wrote: > Commit 9e38e690ace3 ("PCI: tegra: Fix OF node reference leak") has fixed > some node reference leaks in this function but missed some of them. > > In fact, having 'port' referenced in the 'rp' structure is not enough to > prevent the leak, until 'rp' is actually added in the 'pcie->ports' list. > > Add the missing 'goto err_node_put' accordingly. > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/pci/controller/pci-tegra.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) Thierry, Jon, Vidya, please review this series when you have time, thanks. Lorenzo > diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c > index 8069bd9232d4..006bf0346dec 100644 > --- a/drivers/pci/controller/pci-tegra.c > +++ b/drivers/pci/controller/pci-tegra.c > @@ -2193,13 +2193,15 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) > rp->np = port; > > rp->base = devm_pci_remap_cfg_resource(dev, &rp->regs); > - if (IS_ERR(rp->base)) > - return PTR_ERR(rp->base); > + if (IS_ERR(rp->base)) { > + err = PTR_ERR(rp->base); > + goto err_node_put; > + } > > label = devm_kasprintf(dev, GFP_KERNEL, "pex-reset-%u", index); > if (!label) { > - dev_err(dev, "failed to create reset GPIO label\n"); > - return -ENOMEM; > + err = -ENOMEM; > + goto err_node_put; > } > > /* > @@ -2217,7 +2219,8 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) > } else { > dev_err(dev, "failed to get reset GPIO: %ld\n", > PTR_ERR(rp->reset_gpio)); > - return PTR_ERR(rp->reset_gpio); > + err = PTR_ERR(rp->reset_gpio); > + goto err_node_put; > } > } > > -- > 2.30.2 >
Reviewed-by: Vidya Sagar <vidyas@nvidia.com> On 5/4/2021 10:47 PM, Christophe JAILLET wrote: > Commit 9e38e690ace3 ("PCI: tegra: Fix OF node reference leak") has fixed > some node reference leaks in this function but missed some of them. > > In fact, having 'port' referenced in the 'rp' structure is not enough to > prevent the leak, until 'rp' is actually added in the 'pcie->ports' list. > > Add the missing 'goto err_node_put' accordingly. > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/pci/controller/pci-tegra.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c > index 8069bd9232d4..006bf0346dec 100644 > --- a/drivers/pci/controller/pci-tegra.c > +++ b/drivers/pci/controller/pci-tegra.c > @@ -2193,13 +2193,15 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) > rp->np = port; > > rp->base = devm_pci_remap_cfg_resource(dev, &rp->regs); > - if (IS_ERR(rp->base)) > - return PTR_ERR(rp->base); > + if (IS_ERR(rp->base)) { > + err = PTR_ERR(rp->base); > + goto err_node_put; > + } > > label = devm_kasprintf(dev, GFP_KERNEL, "pex-reset-%u", index); > if (!label) { > - dev_err(dev, "failed to create reset GPIO label\n"); > - return -ENOMEM; > + err = -ENOMEM; > + goto err_node_put; > } > > /* > @@ -2217,7 +2219,8 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) > } else { > dev_err(dev, "failed to get reset GPIO: %ld\n", > PTR_ERR(rp->reset_gpio)); > - return PTR_ERR(rp->reset_gpio); > + err = PTR_ERR(rp->reset_gpio); > + goto err_node_put; > } > } > >
On Tue, 4 May 2021 19:17:42 +0200, Christophe JAILLET wrote: > Commit 9e38e690ace3 ("PCI: tegra: Fix OF node reference leak") has fixed > some node reference leaks in this function but missed some of them. > > In fact, having 'port' referenced in the 'rp' structure is not enough to > prevent the leak, until 'rp' is actually added in the 'pcie->ports' list. > > Add the missing 'goto err_node_put' accordingly. Applied to pci/tegra, thanks! [1/3] PCI: tegra: Fix OF node reference leak https://git.kernel.org/lpieralisi/pci/c/eff21f5da3 [2/3] PCI: tegra: Use 'seq_puts' instead of 'seq_printf' https://git.kernel.org/lpieralisi/pci/c/804b2b6f2a [3/3] PCI: tegra: make const array err_msg static https://git.kernel.org/lpieralisi/pci/c/fd44e8efcc Thanks, Lorenzo
diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c index 8069bd9232d4..006bf0346dec 100644 --- a/drivers/pci/controller/pci-tegra.c +++ b/drivers/pci/controller/pci-tegra.c @@ -2193,13 +2193,15 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) rp->np = port; rp->base = devm_pci_remap_cfg_resource(dev, &rp->regs); - if (IS_ERR(rp->base)) - return PTR_ERR(rp->base); + if (IS_ERR(rp->base)) { + err = PTR_ERR(rp->base); + goto err_node_put; + } label = devm_kasprintf(dev, GFP_KERNEL, "pex-reset-%u", index); if (!label) { - dev_err(dev, "failed to create reset GPIO label\n"); - return -ENOMEM; + err = -ENOMEM; + goto err_node_put; } /* @@ -2217,7 +2219,8 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) } else { dev_err(dev, "failed to get reset GPIO: %ld\n", PTR_ERR(rp->reset_gpio)); - return PTR_ERR(rp->reset_gpio); + err = PTR_ERR(rp->reset_gpio); + goto err_node_put; } }
Commit 9e38e690ace3 ("PCI: tegra: Fix OF node reference leak") has fixed some node reference leaks in this function but missed some of them. In fact, having 'port' referenced in the 'rp' structure is not enough to prevent the leak, until 'rp' is actually added in the 'pcie->ports' list. Add the missing 'goto err_node_put' accordingly. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- drivers/pci/controller/pci-tegra.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)