Skip to content

Commit e5cfc09

Browse files
javiercarrascocruzdlezcano
authored andcommitted
clocksource/drivers/timer-ti-dm: Fix child node refcount handling
of_find_compatible_node() increments the node's refcount, and it must be decremented again with a call to of_node_put() when the pointer is no longer required to avoid leaking the resource. Instead of adding the missing calls to of_node_put() in all execution paths, use the cleanup attribute for 'arm_timer' by means of the __free() macro, which automatically calls of_node_put() when the variable goes out of scope. Fixes: 25de4ce ("clocksource/drivers/timer-ti-dm: Handle dra7 timer wrap errata i940") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://lore.kernel.org/r/20241031-timer-ti-dm-systimer-of_node_put-v3-1-063ee822b73a@gmail.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent ae4705e commit e5cfc09

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/clocksource/timer-ti-dm-systimer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,9 @@ subsys_initcall(dmtimer_percpu_timer_startup);
686686

687687
static int __init dmtimer_percpu_quirk_init(struct device_node *np, u32 pa)
688688
{
689-
struct device_node *arm_timer;
689+
struct device_node *arm_timer __free(device_node) =
690+
of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
690691

691-
arm_timer = of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
692692
if (of_device_is_available(arm_timer)) {
693693
pr_warn_once("ARM architected timer wrap issue i940 detected\n");
694694
return 0;

0 commit comments

Comments
 (0)