All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] net: dsa: fix a leaked reference by adding a missing of_node_put
@ 2019-02-22  7:15 ` Wen Yang
  0 siblings, 0 replies; 26+ messages in thread
From: Wen Yang @ 2019-02-22  7:15 UTC (permalink / raw)
  To: linus.walleij
  Cc: andrew, vivien.didelot, f.fainelli, davem, netdev, linux-kernel,
	alexandre.belloni, UNGLinuxDriver, nbd, lorenzo.bianconi83,
	kvalo, matthias.bgg, linux-wireless, linux-arm-kernel,
	linux-mediatek, anirudh, John.Linn, michal.simek, 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.

Detected by coccinelle with the following warnings:
./drivers/net/dsa/rtl8366rb.c:510:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:518:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:540:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:548:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:556:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.
./drivers/net/dsa/rtl8366rb.c:561:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 501, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Vivien Didelot <vivien.didelot@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/dsa/rtl8366rb.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c
index a4d5049..f4b14b6 100644
--- a/drivers/net/dsa/rtl8366rb.c
+++ b/drivers/net/dsa/rtl8366rb.c
@@ -507,7 +507,8 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 	irq = of_irq_get(intc, 0);
 	if (irq <= 0) {
 		dev_err(smi->dev, "failed to get parent IRQ\n");
-		return irq ? irq : -EINVAL;
+		ret = irq ? irq : -EINVAL;
+		goto out_put_node;
 	}
 
 	/* This clears the IRQ status register */
@@ -515,7 +516,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 			  &val);
 	if (ret) {
 		dev_err(smi->dev, "can't read interrupt status\n");
-		return ret;
+		goto out_put_node;
 	}
 
 	/* Fetch IRQ edge information from the descriptor */
@@ -537,7 +538,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 				 val);
 	if (ret) {
 		dev_err(smi->dev, "could not configure IRQ polarity\n");
-		return ret;
+		goto out_put_node;
 	}
 
 	ret = devm_request_threaded_irq(smi->dev, irq, NULL,
@@ -545,7 +546,7 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 					"RTL8366RB", smi);
 	if (ret) {
 		dev_err(smi->dev, "unable to request irq: %d\n", ret);
-		return ret;
+		goto out_put_node;
 	}
 	smi->irqdomain = irq_domain_add_linear(intc,
 					       RTL8366RB_NUM_INTERRUPT,
@@ -553,12 +554,15 @@ static int rtl8366rb_setup_cascaded_irq(struct realtek_smi *smi)
 					       smi);
 	if (!smi->irqdomain) {
 		dev_err(smi->dev, "failed to create IRQ domain\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out_put_node;
 	}
 	for (i = 0; i < smi->num_ports; i++)
 		irq_set_parent(irq_create_mapping(smi->irqdomain, i), irq);
 
-	return 0;
+out_put_node:
+	of_node_put(intc);
+	return ret;
 }
 
 static int rtl8366rb_set_addr(struct realtek_smi *smi)
-- 
2.9.5


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

end of thread, other threads:[~2019-04-08  7:38 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22  7:15 [PATCH 1/5] net: dsa: fix a leaked reference by adding a missing of_node_put Wen Yang
2019-02-22  7:15 ` Wen Yang
2019-02-22  7:15 ` [PATCH 2/5] net: mscc: ocelot: " Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-22  7:15 ` [PATCH 3/5] mt76: " Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-28  8:39   ` Kalle Valo
2019-02-28  8:39     ` Kalle Valo
2019-02-28  8:39   ` Kalle Valo
2019-02-28  8:39     ` Kalle Valo
2019-04-05 13:15   ` Markus Elfring
2019-04-05 13:15     ` Markus Elfring
     [not found]     ` <799adbb0-23a6-bf20-f22d-4af68e9d0012-S0/GAf8tV78@public.gmane.org>
2019-04-08  6:55       ` [PATCH 3/5] mt76: fix a leaked reference by adding a missingof_node_put wen.yang99-Th6q7B73Y6EnDS1+zs4M5A
2019-04-08  7:37         ` Markus Elfring
2019-04-08  7:37           ` Markus Elfring
2019-02-22  7:15 ` [PATCH 4/5] net: xilinx: fix a leaked reference by adding missing of_node_put Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-22  7:15 ` [PATCH 5/5] net: dsa: " Wen Yang
2019-02-22  7:15   ` Wen Yang
2019-02-24 20:32   ` David Miller
2019-02-24 20:32     ` David Miller
2019-02-22 10:38 ` [PATCH 1/5] net: dsa: fix a leaked reference by adding a " Linus Walleij
2019-02-22 10:38   ` Linus Walleij
2019-02-22 10:38   ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.