linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: faraday: add missing of_node_put()
@ 2018-06-23 15:14 Nicholas Mc Guire
  2018-06-26  7:21 ` Linus Walleij
  2018-06-29 13:44 ` Lorenzo Pieralisi
  0 siblings, 2 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2018-06-23 15:14 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Lorenzo Pieralisi, Bjorn Helgaas, linux-pci, linux-kernel,
	Nicholas Mc Guire

 The call to of_get_next_child() returns a node pointer with refcount
incremented thus it must be explicitly decremented here in the error
path and after the last usage.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: commit d3c68e0a7e34 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI Host Bridge driver")
---

Patch found my experimental coccinelle script

Patch was compile tested with: gemini_defconfig (implies CONFIG_PCI_FTPCI100=y)

Patch is against 4.18-rc1 (localversion-next is next-20180621)

 drivers/pci/controller/pci-ftpci100.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c
index a1ebe9e..20bb256 100644
--- a/drivers/pci/controller/pci-ftpci100.c
+++ b/drivers/pci/controller/pci-ftpci100.c
@@ -355,11 +355,13 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
 	irq = of_irq_get(intc, 0);
 	if (irq <= 0) {
 		dev_err(p->dev, "failed to get parent IRQ\n");
+		of_node_put(intc);
 		return irq ?: -EINVAL;
 	}
 
 	p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX,
 					     &faraday_pci_irqdomain_ops, p);
+	of_node_put(intc);
 	if (!p->irqdomain) {
 		dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n");
 		return -EINVAL;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: faraday: add missing of_node_put()
  2018-06-23 15:14 [PATCH] PCI: faraday: add missing of_node_put() Nicholas Mc Guire
@ 2018-06-26  7:21 ` Linus Walleij
  2018-06-29 13:44 ` Lorenzo Pieralisi
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2018-06-26  7:21 UTC (permalink / raw)
  To: Nicholas Mc Guire
  Cc: Lorenzo Pieralisi, Bjorn Helgaas, linux-pci, linux-kernel

On Sat, Jun 23, 2018 at 5:16 PM Nicholas Mc Guire <hofrat@osadl.org> wrote:

>  The call to of_get_next_child() returns a node pointer with refcount
> incremented thus it must be explicitly decremented here in the error
> path and after the last usage.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> Fixes: commit d3c68e0a7e34 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI Host Bridge driver")

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: faraday: add missing of_node_put()
  2018-06-23 15:14 [PATCH] PCI: faraday: add missing of_node_put() Nicholas Mc Guire
  2018-06-26  7:21 ` Linus Walleij
@ 2018-06-29 13:44 ` Lorenzo Pieralisi
  1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Pieralisi @ 2018-06-29 13:44 UTC (permalink / raw)
  To: Nicholas Mc Guire; +Cc: Linus Walleij, Bjorn Helgaas, linux-pci, linux-kernel

On Sat, Jun 23, 2018 at 05:14:59PM +0200, Nicholas Mc Guire wrote:
>  The call to of_get_next_child() returns a node pointer with refcount
> incremented thus it must be explicitly decremented here in the error
> path and after the last usage.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> Fixes: commit d3c68e0a7e34 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI Host Bridge driver")
> ---
> 
> Patch found my experimental coccinelle script
> 
> Patch was compile tested with: gemini_defconfig (implies CONFIG_PCI_FTPCI100=y)
> 
> Patch is against 4.18-rc1 (localversion-next is next-20180621)
> 
>  drivers/pci/controller/pci-ftpci100.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied to pci/controller-fixes to be tentatively merged for -rc4,
thanks.

Lorenzo

> diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c
> index a1ebe9e..20bb256 100644
> --- a/drivers/pci/controller/pci-ftpci100.c
> +++ b/drivers/pci/controller/pci-ftpci100.c
> @@ -355,11 +355,13 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
>  	irq = of_irq_get(intc, 0);
>  	if (irq <= 0) {
>  		dev_err(p->dev, "failed to get parent IRQ\n");
> +		of_node_put(intc);
>  		return irq ?: -EINVAL;
>  	}
>  
>  	p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX,
>  					     &faraday_pci_irqdomain_ops, p);
> +	of_node_put(intc);
>  	if (!p->irqdomain) {
>  		dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n");
>  		return -EINVAL;
> -- 
> 2.1.4
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-29 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-23 15:14 [PATCH] PCI: faraday: add missing of_node_put() Nicholas Mc Guire
2018-06-26  7:21 ` Linus Walleij
2018-06-29 13:44 ` Lorenzo Pieralisi

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).