[PATCH] xtensa: kernel: Fix refcount leak bug in time.c

Liang He posted 1 patch 3 years, 10 months ago
arch/xtensa/kernel/time.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] xtensa: kernel: Fix refcount leak bug in time.c
Posted by Liang He 3 years, 10 months ago
In calibrate_ccount(), of_find_compatible_node() will return a node
pointer with refcount incremented. We should use of_node_put() when
it is not used anymore.

Signed-off-by: Liang He <windhl@126.com>
---
 arch/xtensa/kernel/time.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index e8ceb1528608..16b8a6273772 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -154,6 +154,7 @@ static void __init calibrate_ccount(void)
 	cpu = of_find_compatible_node(NULL, NULL, "cdns,xtensa-cpu");
 	if (cpu) {
 		clk = of_clk_get(cpu, 0);
+		of_node_put(cpu);
 		if (!IS_ERR(clk)) {
 			ccount_freq = clk_get_rate(clk);
 			return;
-- 
2.25.1
Re: [PATCH] xtensa: kernel: Fix refcount leak bug in time.c
Posted by Max Filippov 3 years, 10 months ago
On Fri, Jun 17, 2022 at 5:44 AM Liang He <windhl@126.com> wrote:
>
> In calibrate_ccount(), of_find_compatible_node() will return a node
> pointer with refcount incremented. We should use of_node_put() when
> it is not used anymore.
>
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  arch/xtensa/kernel/time.c | 1 +
>  1 file changed, 1 insertion(+)

Thanks. Applied to my xtensa tree.

-- Max