[PATCH 1/2] perf/x86/amd/power: Fix missing CPU hotplug setup check and cleanup

From: Ayush Yaduvanshi

Date: Thu Nov 12 2026 - 19:14:12 EST


Check the return value of cpuhp_setup_state() and remove the hotplug
state if perf_pmu_register() fails.

Signed-off-by: Ayush Yaduvanshi <ayush37735@xxxxxxxxx>
---
arch/x86/events/amd/power.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c
index 66197214b010..2627d5269b52 100644
--- a/arch/x86/events/amd/power.c
+++ b/arch/x86/events/amd/power.c
@@ -282,13 +282,16 @@ static int __init amd_power_pmu_init(void)
}


- cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_POWER_ONLINE,
- "perf/x86/amd/power:online",
- power_cpu_init, power_cpu_exit);
+ ret = cpuhp_setup_state(CPUHP_AP_PERF_X86_AMD_POWER_ONLINE,
+ "perf/x86/amd/power:online",
+ power_cpu_init, power_cpu_exit);
+ if (ret)
+ return ret;

ret = perf_pmu_register(&pmu_class, "power", -1);
if (WARN_ON(ret)) {
pr_warn("AMD Power PMU registration failed\n");
+ cpuhp_remove_state(CPUHP_AP_PERF_X86_AMD_POWER_ONLINE);
return ret;
}

--
2.53.0