Skip to content

Commit

Permalink
cpufreq: amd-pstate: Don't create attributes when registration fails
Browse files Browse the repository at this point in the history
If driver registration fails then immediately return the failure
instead of continuing to register attributes.

This fixes issues of falling back from amd-pstate to other drivers
when cpufreq init has failed for any reason.

Reported-by: alex.s.cochran@proton.me
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Reviewed-by: Perry Yuan <Perry.Yuan@amd.com>
Link: https://lore.kernel.org/r/20240623200918.52104-1-mario.limonciello@amd.com
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
  • Loading branch information
superm1 committed Jun 24, 2024
1 parent e1a921f commit bc76f57
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/cpufreq/amd-pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1863,8 +1863,10 @@ static int __init amd_pstate_init(void)
}

ret = cpufreq_register_driver(current_pstate_driver);
if (ret)
if (ret) {
pr_err("failed to register with return %d\n", ret);
goto disable_driver;
}

dev_root = bus_get_dev_root(&cpu_subsys);
if (dev_root) {
Expand All @@ -1880,6 +1882,8 @@ static int __init amd_pstate_init(void)

global_attr_free:
cpufreq_unregister_driver(current_pstate_driver);
disable_driver:
amd_pstate_enable(false);
return ret;
}
device_initcall(amd_pstate_init);
Expand Down

0 comments on commit bc76f57

Please sign in to comment.