linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm: mach-versatile: Fix refcount leak bug in tc2_pm
@ 2022-06-17 12:30 Liang He
  2023-09-13 12:16 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-06-17 12:30 UTC (permalink / raw)
  To: linus.walleij, linux; +Cc: windhl, linux-arm-kernel, linux-kernel

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

Signed-off-by: Liang He <windhl@126.com>
---
 arch/arm/mach-versatile/tc2_pm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-versatile/tc2_pm.c b/arch/arm/mach-versatile/tc2_pm.c
index 0fe78da0c109..2a7aeab7b3da 100644
--- a/arch/arm/mach-versatile/tc2_pm.c
+++ b/arch/arm/mach-versatile/tc2_pm.c
@@ -212,19 +212,24 @@ static int __init tc2_pm_init(void)
 	np = of_find_compatible_node(NULL, NULL,
 			"arm,vexpress-scc,v2p-ca15_a7");
 	scc = of_iomap(np, 0);
-	if (!scc)
+	if (!scc) {
+		of_node_put(np);
 		return -ENODEV;
+	}
 
 	a15_cluster_id = readl_relaxed(scc + A15_CONF) & 0xf;
 	a7_cluster_id = readl_relaxed(scc + A7_CONF) & 0xf;
-	if (a15_cluster_id >= TC2_CLUSTERS || a7_cluster_id >= TC2_CLUSTERS)
+	if (a15_cluster_id >= TC2_CLUSTERS || a7_cluster_id >= TC2_CLUSTERS) {
+		of_node_put(np);
 		return -EINVAL;
+	}
 
 	sys_info = readl_relaxed(scc + SYS_INFO);
 	tc2_nr_cpus[a15_cluster_id] = (sys_info >> 16) & 0xf;
 	tc2_nr_cpus[a7_cluster_id] = (sys_info >> 20) & 0xf;
 
 	irq = irq_of_parse_and_map(np, 0);
+	of_node_put(np);
 
 	/*
 	 * A subset of the SCC registers is also used to communicate
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm: mach-versatile: Fix refcount leak bug in tc2_pm
  2022-06-17 12:30 [PATCH] arm: mach-versatile: Fix refcount leak bug in tc2_pm Liang He
@ 2023-09-13 12:16 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2023-09-13 12:16 UTC (permalink / raw)
  To: Liang He; +Cc: linux, linux-arm-kernel, linux-kernel

On Fri, Jun 17, 2022 at 2:30 PM Liang He <windhl@126.com> wrote:

> In tc2_pm_init(), of_find_compatible_node() will return a node pointer
> with refcount incremented. We should use of_node_put() in fail path or
> when it is not used anymore.
>
> Signed-off-by: Liang He <windhl@126.com>

Patch applied.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-09-13 12:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-17 12:30 [PATCH] arm: mach-versatile: Fix refcount leak bug in tc2_pm Liang He
2023-09-13 12:16 ` Linus Walleij

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