linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put
@ 2019-02-27  4:40 Wen Yang
  2019-02-27  4:40 ` [PATCH 2/8] PCI: uniphier: " Wen Yang
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Wen Yang @ 2019-02-27  4:40 UTC (permalink / raw)
  To: benh
  Cc: paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59,
	Wen Yang

The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/dwc/pci-dra7xx.c:252:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
./drivers/pci/controller/dwc/pci-dra7xx.c:255:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-omap@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/dwc/pci-dra7xx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
index ae84a69..627c91d 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -247,6 +247,7 @@ static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp)
 
 	dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
 						   &intx_domain_ops, pp);
+	of_node_put(pcie_intc_node);
 	if (!dra7xx->irq_domain) {
 		dev_err(dev, "Failed to get a INTx IRQ domain\n");
 		return -ENODEV;
-- 
2.9.5


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

* [PATCH 2/8] PCI: uniphier: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
@ 2019-02-27  4:40 ` Wen Yang
  2019-02-27  4:40 ` [PATCH 3/8] PCI: dwc: layerscape: " Wen Yang
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Wen Yang @ 2019-02-27  4:40 UTC (permalink / raw)
  To: benh
  Cc: paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59,
	Wen Yang

The call to of_get_child_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/dwc/pcie-uniphier.c:283:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function.
./drivers/pci/controller/dwc/pcie-uniphier.c:290:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function.
./drivers/pci/controller/dwc/pcie-uniphier.c:296:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: linux-pci@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/dwc/pcie-uniphier.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-uniphier.c b/drivers/pci/controller/dwc/pcie-uniphier.c
index d5dc402..3f30ee4 100644
--- a/drivers/pci/controller/dwc/pcie-uniphier.c
+++ b/drivers/pci/controller/dwc/pcie-uniphier.c
@@ -270,6 +270,7 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp)
 	struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci);
 	struct device_node *np = pci->dev->of_node;
 	struct device_node *np_intc;
+	int ret = 0;
 
 	np_intc = of_get_child_by_name(np, "legacy-interrupt-controller");
 	if (!np_intc) {
@@ -280,20 +281,24 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp)
 	pp->irq = irq_of_parse_and_map(np_intc, 0);
 	if (!pp->irq) {
 		dev_err(pci->dev, "Failed to get an IRQ entry in legacy-interrupt-controller\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out_put_node;
 	}
 
 	priv->legacy_irq_domain = irq_domain_add_linear(np_intc, PCI_NUM_INTX,
 						&uniphier_intx_domain_ops, pp);
 	if (!priv->legacy_irq_domain) {
 		dev_err(pci->dev, "Failed to get INTx domain\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto out_put_node;
 	}
 
 	irq_set_chained_handler_and_data(pp->irq, uniphier_pcie_irq_handler,
 					 pp);
 
-	return 0;
+out_put_node:
+	of_node_put(np_intc);
+	return ret;
 }
 
 static int uniphier_pcie_host_init(struct pcie_port *pp)
-- 
2.9.5


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

* [PATCH 3/8] PCI: dwc: layerscape: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
  2019-02-27  4:40 ` [PATCH 2/8] PCI: uniphier: " Wen Yang
@ 2019-02-27  4:40 ` Wen Yang
  2019-02-27  4:40 ` [PATCH 4/8] PCI: rockchip: " Wen Yang
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Wen Yang @ 2019-02-27  4:40 UTC (permalink / raw)
  To: benh
  Cc: paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59,
	Wen Yang

The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/dwc/pci-layerscape.c:204:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 198, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Minghuan Lian <minghuan.Lian@nxp.com>
Cc: Mingkai Hu <mingkai.hu@nxp.com>
Cc: Roy Zang <roy.zang@nxp.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-pci@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/dwc/pci-layerscape.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c
index ce45bde2..3a5fa26 100644
--- a/drivers/pci/controller/dwc/pci-layerscape.c
+++ b/drivers/pci/controller/dwc/pci-layerscape.c
@@ -201,6 +201,7 @@ static int ls_pcie_msi_host_init(struct pcie_port *pp)
 		return -EINVAL;
 	}
 
+	of_node_put(msi_node);
 	return 0;
 }
 
-- 
2.9.5


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

* [PATCH 4/8] PCI: rockchip: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
  2019-02-27  4:40 ` [PATCH 2/8] PCI: uniphier: " Wen Yang
  2019-02-27  4:40 ` [PATCH 3/8] PCI: dwc: layerscape: " Wen Yang
@ 2019-02-27  4:40 ` Wen Yang
  2019-02-27  4:40 ` [PATCH 5/8] PCI: aardvark: " Wen Yang
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Wen Yang @ 2019-02-27  4:40 UTC (permalink / raw)
  To: benh
  Cc: paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59,
	Wen Yang

The call to of_get_child_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/pcie-rockchip-host.c:729:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 718, but without a corresponding object release within this function.
./drivers/pci/controller/pcie-rockchip-host.c:732:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 718, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Shawn Lin <shawn.lin@rock-chips.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-pci@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/pcie-rockchip-host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c
index 1372d27..8d20f17 100644
--- a/drivers/pci/controller/pcie-rockchip-host.c
+++ b/drivers/pci/controller/pcie-rockchip-host.c
@@ -724,6 +724,7 @@ static int rockchip_pcie_init_irq_domain(struct rockchip_pcie *rockchip)
 
 	rockchip->irq_domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
 						    &intx_domain_ops, rockchip);
+	of_node_put(intc);
 	if (!rockchip->irq_domain) {
 		dev_err(dev, "failed to get a INTx IRQ domain\n");
 		return -EINVAL;
-- 
2.9.5


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

* [PATCH 5/8] PCI: aardvark: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
                   ` (2 preceding siblings ...)
  2019-02-27  4:40 ` [PATCH 4/8] PCI: rockchip: " Wen Yang
@ 2019-02-27  4:40 ` Wen Yang
  2019-02-27  4:40 ` [PATCH 6/8] PCI: iproc: " Wen Yang
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Wen Yang @ 2019-02-27  4:40 UTC (permalink / raw)
  To: benh
  Cc: paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59,
	Wen Yang

The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/pci-aardvark.c:826:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 798, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/pci-aardvark.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
index 750081c..56ecb16 100644
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
@@ -794,6 +794,7 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
 	struct device_node *node = dev->of_node;
 	struct device_node *pcie_intc_node;
 	struct irq_chip *irq_chip;
+	int ret = 0;
 
 	pcie_intc_node =  of_get_next_child(node, NULL);
 	if (!pcie_intc_node) {
@@ -806,8 +807,8 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
 	irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq",
 					dev_name(dev));
 	if (!irq_chip->name) {
-		of_node_put(pcie_intc_node);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto out_put_node;
 	}
 
 	irq_chip->irq_mask = advk_pcie_irq_mask;
@@ -819,11 +820,13 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
 				      &advk_pcie_irq_domain_ops, pcie);
 	if (!pcie->irq_domain) {
 		dev_err(dev, "Failed to get a INTx IRQ domain\n");
-		of_node_put(pcie_intc_node);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto out_put_node;
 	}
 
-	return 0;
+out_put_node:
+	of_node_put(pcie_intc_node);
+	return ret;
 }
 
 static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie)
-- 
2.9.5


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

* [PATCH 6/8] PCI: iproc: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
                   ` (3 preceding siblings ...)
  2019-02-27  4:40 ` [PATCH 5/8] PCI: aardvark: " Wen Yang
@ 2019-02-27  4:40 ` Wen Yang
  2019-02-27  4:40 ` [PATCH 7/8] PCI: mediatek: " Wen Yang
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Wen Yang @ 2019-02-27  4:40 UTC (permalink / raw)
  To: benh
  Cc: paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59,
	Wen Yang

The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
iproc_msi_init also calls of_node_get to increase refcount
(proc_msi_init -> iproc_msi_alloc_domains -> pci_msi_create_irq_domain
-> msi_create_irq_domain -> irq_domain_create_linear -> __irq_domain_add),
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/pcie-iproc.c:1323:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1299, but without a corresponding object release within this function.
./drivers/pci/controller/pcie-iproc.c:1330:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1299, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-pci@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/controller/pcie-iproc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c
index c20fd6b..9998c5c 100644
--- a/drivers/pci/controller/pcie-iproc.c
+++ b/drivers/pci/controller/pcie-iproc.c
@@ -1320,14 +1320,18 @@ static int iproc_pcie_msi_enable(struct iproc_pcie *pcie)
 	if (pcie->need_msi_steer) {
 		ret = iproc_pcie_msi_steer(pcie, msi_node);
 		if (ret)
-			return ret;
+			goto out_put_node;
 	}
 
 	/*
 	 * If another MSI controller is being used, the call below should fail
 	 * but that is okay
 	 */
-	return iproc_msi_init(pcie, msi_node);
+	ret = iproc_msi_init(pcie, msi_node);
+
+out_put_node:
+	of_node_put(msi_node);
+	return ret;
 }
 
 static void iproc_pcie_msi_disable(struct iproc_pcie *pcie)
-- 
2.9.5


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

* [PATCH 7/8] PCI: mediatek: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
                   ` (4 preceding siblings ...)
  2019-02-27  4:40 ` [PATCH 6/8] PCI: iproc: " Wen Yang
@ 2019-02-27  4:40 ` Wen Yang
  2019-03-01  1:59   ` Honghui Zhang
  2019-02-27  4:40 ` [PATCH 8/8] PCI: rpadlpar: " Wen Yang
  2019-04-01 10:03 ` [PATCH 1/8] PCI: dwc: pci-dra7xx: " Lorenzo Pieralisi
  7 siblings, 1 reply; 10+ messages in thread
From: Wen Yang @ 2019-02-27  4:40 UTC (permalink / raw)
  To: benh
  Cc: paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59,
	Wen Yang

The call to of_get_next_child returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.
irq_domain_add_linear also calls of_node_get to increase refcount,
so irq_domain will not be affected when it is released.

Detected by coccinelle with the following warnings:
./drivers/pci/controller/pcie-mediatek.c:577:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function.
./drivers/pci/controller/pcie-mediatek.c:583:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function.
./drivers/pci/controller/pcie-mediatek.c:586:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Ryder Lee <ryder.lee@mediatek.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-pci@vger.kernel.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/pci/controller/pcie-mediatek.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
index 55e471c..e91716a 100644
--- a/drivers/pci/controller/pcie-mediatek.c
+++ b/drivers/pci/controller/pcie-mediatek.c
@@ -572,6 +572,7 @@ static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port,
 
 	port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
 						 &intx_domain_ops, port);
+	of_node_put(pcie_intc_node);
 	if (!port->irq_domain) {
 		dev_err(dev, "failed to get INTx IRQ domain\n");
 		return -ENODEV;
-- 
2.9.5


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

* [PATCH 8/8] PCI: rpadlpar: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
                   ` (5 preceding siblings ...)
  2019-02-27  4:40 ` [PATCH 7/8] PCI: mediatek: " Wen Yang
@ 2019-02-27  4:40 ` Wen Yang
  2019-04-01 10:03 ` [PATCH 1/8] PCI: dwc: pci-dra7xx: " Lorenzo Pieralisi
  7 siblings, 0 replies; 10+ messages in thread
From: Wen Yang @ 2019-02-27  4:40 UTC (permalink / raw)
  To: benh
  Cc: paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59,
	Wen Yang

The call to of_find_node_by_name returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/pci/hotplug/rpadlpar_core.c:55:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 42, but without a corresponding object release within this function

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/pci/hotplug/rpadlpar_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index e2356a9..f3f42ff 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -52,6 +52,7 @@ static struct device_node *find_vio_slot_node(char *drc_name)
 			break;
 	}
 
+	of_node_put(parent);
 	return dn;
 }
 
-- 
2.9.5


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

* Re: [PATCH 7/8] PCI: mediatek: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 ` [PATCH 7/8] PCI: mediatek: " Wen Yang
@ 2019-03-01  1:59   ` Honghui Zhang
  0 siblings, 0 replies; 10+ messages in thread
From: Honghui Zhang @ 2019-03-01  1:59 UTC (permalink / raw)
  To: Wen Yang
  Cc: benh, paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, lorenzo.pieralisi, matthias.bgg,
	linux-mediatek, linux-arm-kernel, rjui, sbranden,
	bcm-kernel-feedback-list, thomas.petazzoni, shawn.lin, heiko,
	linux-rockchip, minghuan.Lian, mingkai.hu, roy.zang,
	hayashi.kunihiko, yamada.masahiro, kishon, linux-omap, wang.yi59

On Wed, 2019-02-27 at 12:40 +0800, Wen Yang wrote:
> The call to of_get_next_child returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
> irq_domain_add_linear also calls of_node_get to increase refcount,
> so irq_domain will not be affected when it is released.
> 
> Detected by coccinelle with the following warnings:
> ./drivers/pci/controller/pcie-mediatek.c:577:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function.
> ./drivers/pci/controller/pcie-mediatek.c:583:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function.
> ./drivers/pci/controller/pcie-mediatek.c:586:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function.
> 
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Ryder Lee <ryder.lee@mediatek.com>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: linux-pci@vger.kernel.org
> Cc: linux-mediatek@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> ---
>  drivers/pci/controller/pcie-mediatek.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index 55e471c..e91716a 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
> @@ -572,6 +572,7 @@ static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port,
>  
>  	port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
>  						 &intx_domain_ops, port);
> +	of_node_put(pcie_intc_node);
>  	if (!port->irq_domain) {
>  		dev_err(dev, "failed to get INTx IRQ domain\n");
>  		return -ENODEV;

Thanks for fix this.

Acked-by: Honghui Zhang <honghui.zhang@mediatek.com>


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

* Re: [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put
  2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
                   ` (6 preceding siblings ...)
  2019-02-27  4:40 ` [PATCH 8/8] PCI: rpadlpar: " Wen Yang
@ 2019-04-01 10:03 ` Lorenzo Pieralisi
  7 siblings, 0 replies; 10+ messages in thread
From: Lorenzo Pieralisi @ 2019-04-01 10:03 UTC (permalink / raw)
  To: Wen Yang
  Cc: benh, paulus, mpe, tyreld, bhelgaas, linuxppc-dev, linux-pci,
	linux-kernel, ryder.lee, matthias.bgg, linux-mediatek,
	linux-arm-kernel, rjui, sbranden, bcm-kernel-feedback-list,
	thomas.petazzoni, shawn.lin, heiko, linux-rockchip,
	minghuan.Lian, mingkai.hu, roy.zang, hayashi.kunihiko,
	yamada.masahiro, kishon, linux-omap, wang.yi59

On Wed, Feb 27, 2019 at 12:40:36PM +0800, Wen Yang wrote:
> The call to of_get_next_child returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
> irq_domain_add_linear also calls of_node_get to increase refcount,
> so irq_domain will not be affected when it is released.
> 
> Detected by coccinelle with the following warnings:
> ./drivers/pci/controller/dwc/pci-dra7xx.c:252:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
> ./drivers/pci/controller/dwc/pci-dra7xx.c:255:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function.
> 
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Kishon Vijay Abraham I <kishon@ti.com>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-omap@vger.kernel.org
> Cc: linux-pci@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/pci/controller/dwc/pci-dra7xx.c | 1 +
>  1 file changed, 1 insertion(+)

Applied the series to pci/misc for v5.2, thanks.

Lorenzo

> diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
> index ae84a69..627c91d 100644
> --- a/drivers/pci/controller/dwc/pci-dra7xx.c
> +++ b/drivers/pci/controller/dwc/pci-dra7xx.c
> @@ -247,6 +247,7 @@ static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp)
>  
>  	dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
>  						   &intx_domain_ops, pp);
> +	of_node_put(pcie_intc_node);
>  	if (!dra7xx->irq_domain) {
>  		dev_err(dev, "Failed to get a INTx IRQ domain\n");
>  		return -ENODEV;
> -- 
> 2.9.5
> 

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

end of thread, other threads:[~2019-04-01 10:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27  4:40 [PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put Wen Yang
2019-02-27  4:40 ` [PATCH 2/8] PCI: uniphier: " Wen Yang
2019-02-27  4:40 ` [PATCH 3/8] PCI: dwc: layerscape: " Wen Yang
2019-02-27  4:40 ` [PATCH 4/8] PCI: rockchip: " Wen Yang
2019-02-27  4:40 ` [PATCH 5/8] PCI: aardvark: " Wen Yang
2019-02-27  4:40 ` [PATCH 6/8] PCI: iproc: " Wen Yang
2019-02-27  4:40 ` [PATCH 7/8] PCI: mediatek: " Wen Yang
2019-03-01  1:59   ` Honghui Zhang
2019-02-27  4:40 ` [PATCH 8/8] PCI: rpadlpar: " Wen Yang
2019-04-01 10:03 ` [PATCH 1/8] PCI: dwc: pci-dra7xx: " 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).