[PATCH] clocksource: Fix refcount leak bug in time-ti-dm-systimer

From: Liang He
Date: Fri Jun 17 2022 - 09:33:37 EST


In dmtimer_percpu_quirk_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@xxxxxxx>
---
drivers/clocksource/timer-ti-dm-systimer.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/timer-ti-dm-systimer.c b/drivers/clocksource/timer-ti-dm-systimer.c
index 2737407ff069..f414cb553649 100644
--- a/drivers/clocksource/timer-ti-dm-systimer.c
+++ b/drivers/clocksource/timer-ti-dm-systimer.c
@@ -690,10 +690,11 @@ static int __init dmtimer_percpu_quirk_init(struct device_node *np, u32 pa)

arm_timer = of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
if (of_device_is_available(arm_timer)) {
+ of_node_put(arm_timer);
pr_warn_once("ARM architected timer wrap issue i940 detected\n");
return 0;
}
-
+ of_node_put(arm_timer);
if (pa == 0x4882c000) /* dra7 dmtimer15 */
return dmtimer_percpu_timer_init(np, 0);
else if (pa == 0x4882e000) /* dra7 dmtimer16 */
--
2.25.1