]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cpuidle: riscv-sbi: fix device node release in early exit of for_each_possible_cpu
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Fri, 15 Nov 2024 23:32:39 +0000 (00:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Jan 2025 12:34:41 +0000 (13:34 +0100)
commitbb87b494ae7d077b3bc18b467943bff25116e57a
treea997ee3947408fed02569a40311175978508f04c
parent13e41c58c74baa71f34c0830eaa3c29d53a6e964
cpuidle: riscv-sbi: fix device node release in early exit of for_each_possible_cpu

[ Upstream commit 7e25044b804581b9c029d5a28d8800aebde18043 ]

The 'np' device_node is initialized via of_cpu_device_node_get(), which
requires explicit calls to of_node_put() when it 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 'np' by means of the __free()
macro, which automatically calls of_node_put() when the variable goes
out of scope. Given that 'np' is only used within the
for_each_possible_cpu(), reduce its scope to release the nood after
every iteration of the loop.

Fixes: 6abf32f1d9c5 ("cpuidle: Add RISC-V SBI CPU idle driver")
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20241116-cpuidle-riscv-sbi-cleanup-v3-1-a3a46372ce08@gmail.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpuidle/cpuidle-riscv-sbi.c