Commit 40d4071c authored by Xiao Liang's avatar Xiao Liang Committed by Thomas Gleixner

perf/x86/amd/power: Do not load AMD power module on !AMD platforms

The AMD power module can be loaded on non AMD platforms, but unload fails
with the following Oops:

 BUG: unable to handle kernel NULL pointer dereference at           (null)
 IP: __list_del_entry_valid+0x29/0x90
 Call Trace:
  amd_power_pmu_exit+0x1c/0xd23 [power]
  ? exit_to_usermode_loop+0x8f/0xb0

Return -ENODEV instead of 0 from the module init function if the CPU does
not match.

Fixes: c7ab62bf ("perf/x86/amd/power: Add AMD accumulated power reporting mechanism")
Signed-off-by: default avatarXiao Liang <>
Signed-off-by: default avatarThomas Gleixner <>
parent 1f07476e
......@@ -277,7 +277,7 @@ static int __init amd_power_pmu_init(void)
int ret;
if (!x86_match_cpu(cpu_match))
return 0;
return -ENODEV;
if (!boot_cpu_has(X86_FEATURE_ACC_POWER))
return -ENODEV;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment