All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: soc: sifive: Add missing of_node_put() in sifive_l2_cache.c
@ 2022-06-15 12:23 ` Liang He
  0 siblings, 0 replies; 13+ messages in thread
From: Liang He @ 2022-06-15 12:23 UTC (permalink / raw)
  To: palmer, paul.walmsley, aou; +Cc: linux-riscv, linux-kernel, windhl

In sifive_l2_init(), of_find_matching_node() will return a node pointer
with refcount incremented. We should use of_node_put() in each fail path
or when it is not used anymore.

Signed-off-by: Liang He <windhl@126.com>
---
 drivers/soc/sifive/sifive_l2_cache.c | 29 ++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/soc/sifive/sifive_l2_cache.c b/drivers/soc/sifive/sifive_l2_cache.c
index 59640a1d0b28..2b9c9522ef21 100644
--- a/drivers/soc/sifive/sifive_l2_cache.c
+++ b/drivers/soc/sifive/sifive_l2_cache.c
@@ -198,29 +198,41 @@ static int __init sifive_l2_init(void)
 	struct resource res;
 	int i, rc, intr_num;
 
+	int ret;
+
 	np = of_find_matching_node(NULL, sifive_l2_ids);
 	if (!np)
 		return -ENODEV;
 
 	if (of_address_to_resource(np, 0, &res))
-		return -ENODEV;
+	{
+		ret = -ENODEV;
+		goto out_put;
+	}
 
 	l2_base = ioremap(res.start, resource_size(&res));
 	if (!l2_base)
-		return -ENOMEM;
+	{
+		ret = -ENOMEM;
+		goto out_put;
+	}
 
 	intr_num = of_property_count_u32_elems(np, "interrupts");
-	if (!intr_num) {
+	if (!intr_num) {		
 		pr_err("L2CACHE: no interrupts property\n");
-		return -ENODEV;
+		ret = -ENODEV
+		goto out_put;
 	}
 
 	for (i = 0; i < intr_num; i++) {
 		g_irq[i] = irq_of_parse_and_map(np, i);
 		rc = request_irq(g_irq[i], l2_int_handler, 0, "l2_ecc", NULL);
+		
 		if (rc) {
+			
 			pr_err("L2CACHE: Could not request IRQ %d\n", g_irq[i]);
-			return rc;
+			ret = rc;
+			goto out_put;
 		}
 	}
 
@@ -232,6 +244,11 @@ static int __init sifive_l2_init(void)
 #ifdef CONFIG_DEBUG_FS
 	setup_sifive_debug();
 #endif
-	return 0;
+	ret = 0;
+	
+	
+out_put:
+	of_node_put(np);
+	return ret;
 }
 device_initcall(sifive_l2_init);
-- 
2.25.1


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

end of thread, other threads:[~2022-06-16 18:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 12:23 [PATCH] drivers: soc: sifive: Add missing of_node_put() in sifive_l2_cache.c Liang He
2022-06-15 12:23 ` Liang He
2022-06-15 21:58 ` kernel test robot
2022-06-15 21:58   ` kernel test robot
2022-06-16  4:54   ` Liang He
2022-06-16  4:54     ` Liang He
2022-06-16  4:54     ` Liang He
2022-06-16  5:12 ` Christophe JAILLET
2022-06-16  5:12   ` Christophe JAILLET
2022-06-16  5:33   ` Liang He
2022-06-16  5:33     ` Liang He
2022-06-16 18:45     ` Christophe JAILLET
2022-06-16 18:45       ` Christophe JAILLET

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.