All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] sparc: Fix reference leak in scan_of_devices
@ 2022-06-07  3:32 Miaoqian Lin
  2022-06-07  3:32 ` [PATCH 3/3] sparc: prom: Fix reference leak in of_console_init Miaoqian Lin
  2022-06-07  3:33 ` [PATCH 1/3] sparc: kernel: Fix reference leak in jbusmc_probe Miaoqian Lin
  0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-06-07  3:32 UTC (permalink / raw)
  To: David S. Miller, Miaoqian Lin, sparclinux, linux-kernel

of_find_node_by_path() returns a node pointer with
refcount incremented, we should use of_node_put() on it when not need
anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: cf44bbc26cf1 ("[SPARC]: Beginnings of generic of_device framework.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 arch/sparc/kernel/of_device_32.c | 4 +++-
 arch/sparc/kernel/of_device_64.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c
index 4ebf51e6e78e..020b1c023d75 100644
--- a/arch/sparc/kernel/of_device_32.c
+++ b/arch/sparc/kernel/of_device_32.c
@@ -412,8 +412,10 @@ static int __init scan_of_devices(void)
 	struct platform_device *parent;
 
 	parent = scan_one_device(root, NULL);
-	if (!parent)
+	if (!parent) {
+		of_node_put(root);
 		return 0;
+	}
 
 	scan_tree(root->child, &parent->dev);
 	return 0;
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index 5a9f86b1d4e7..f044b4c1975b 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -705,8 +705,10 @@ static int __init scan_of_devices(void)
 	struct platform_device *parent;
 
 	parent = scan_one_device(root, NULL);
-	if (!parent)
+	if (!parent) {
+		of_node_put(root);
 		return 0;
+	}
 
 	scan_tree(root->child, &parent->dev);
 	return 0;
-- 
2.25.1


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

* [PATCH 3/3] sparc: prom: Fix reference leak in of_console_init
  2022-06-07  3:32 [PATCH 2/3] sparc: Fix reference leak in scan_of_devices Miaoqian Lin
@ 2022-06-07  3:32 ` Miaoqian Lin
  2022-06-07  3:33 ` [PATCH 1/3] sparc: kernel: Fix reference leak in jbusmc_probe Miaoqian Lin
  1 sibling, 0 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-06-07  3:32 UTC (permalink / raw)
  To: David S. Miller, Miaoqian Lin, sparclinux, linux-kernel

of_find_node_by_path() returns a node pointer with
refcount incremented, we should use of_node_put() on it when not need
anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: c73fcc846c91 ("[SPARC]: Fix serial console device detection.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 arch/sparc/kernel/prom_32.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sparc/kernel/prom_32.c b/arch/sparc/kernel/prom_32.c
index 3df960c137f7..7fc1c2dc31d5 100644
--- a/arch/sparc/kernel/prom_32.c
+++ b/arch/sparc/kernel/prom_32.c
@@ -295,6 +295,7 @@ void __init of_console_init(void)
 
 			dp = of_find_node_by_path("/");
 			path = of_get_property(dp, "stdout-path", NULL);
+			of_node_put(dp);
 			if (!path) {
 				prom_printf("No stdout-path in root node.\n");
 				prom_halt();
-- 
2.25.1


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

* [PATCH 1/3] sparc: kernel: Fix reference leak in jbusmc_probe
  2022-06-07  3:32 [PATCH 2/3] sparc: Fix reference leak in scan_of_devices Miaoqian Lin
  2022-06-07  3:32 ` [PATCH 3/3] sparc: prom: Fix reference leak in of_console_init Miaoqian Lin
@ 2022-06-07  3:33 ` Miaoqian Lin
  1 sibling, 0 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-06-07  3:33 UTC (permalink / raw)
  To: David S. Miller, Miaoqian Lin, sparclinux, linux-kernel

of_find_node_by_path() returns a node pointer with refcount incremented,
we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: 85269eb5542b ("sparc64: Add JBUS UltraSPARC-IIIi support to memory controller driver.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 arch/sparc/kernel/chmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sparc/kernel/chmc.c b/arch/sparc/kernel/chmc.c
index 6ff43df740e0..9cc1b92ffff9 100644
--- a/arch/sparc/kernel/chmc.c
+++ b/arch/sparc/kernel/chmc.c
@@ -409,6 +409,7 @@ static int jbusmc_probe(struct platform_device *op)
 		goto out;
 	}
 	mem_regs = of_get_property(mem_node, "reg", &len);
+	of_node_put(mem_node);
 	if (!mem_regs) {
 		printk(KERN_ERR PFX "Cannot get reg property of /memory node.\n");
 		goto out;
-- 
2.25.1


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

end of thread, other threads:[~2022-06-07  3:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-07  3:32 [PATCH 2/3] sparc: Fix reference leak in scan_of_devices Miaoqian Lin
2022-06-07  3:32 ` [PATCH 3/3] sparc: prom: Fix reference leak in of_console_init Miaoqian Lin
2022-06-07  3:33 ` [PATCH 1/3] sparc: kernel: Fix reference leak in jbusmc_probe Miaoqian Lin

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.