diff mbox series

[1/2] cpuidle: riscv-sbi: fix device node release in early exit of for_each_possible_cpu

Message ID 20241030-cpuidle-riscv-sbi-cleanup-v1-1-5e08a22c9409@gmail.com (mailing list archive)
State Superseded
Headers show
Series cpuidle: riscv-sbi: fix device node release in early exit of for_each_possible_cpu | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 138.27s
conchuod/patch-1-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 1301.84s
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 1515.61s
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 20.92s
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 22.95s
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh took 0.44s
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 45.04s
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.00s
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.54s
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.02s
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.03s

Commit Message

Javier Carrasco Oct. 30, 2024, 6:44 a.m. UTC
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.

Add the missing calls to of_node_put(np) in all execution paths.

Cc: stable@vger.kernel.org
Fixes: 6abf32f1d9c5 ("cpuidle: Add RISC-V SBI CPU idle driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/cpuidle/cpuidle-riscv-sbi.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c
index 14462c092039..2b3aec09b895 100644
--- a/drivers/cpuidle/cpuidle-riscv-sbi.c
+++ b/drivers/cpuidle/cpuidle-riscv-sbi.c
@@ -513,11 +513,14 @@  static int sbi_cpuidle_probe(struct platform_device *pdev)
 		if (np &&
 		    of_property_present(np, "power-domains") &&
 		    of_property_present(np, "power-domain-names")) {
+			of_node_put(np);
 			continue;
 		} else {
 			sbi_cpuidle_use_osi = false;
+			of_node_put(np);
 			break;
 		}
+		of_node_put(np);
 	}
 
 	/* Populate generic power domains from DT nodes */