Skip to content

Commit bc76f57

Browse files
committed
cpufreq: amd-pstate: Don't create attributes when registration fails
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: [email protected] Reviewed-by: Gautham R. Shenoy <[email protected]> Reviewed-by: Perry Yuan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mario Limonciello <[email protected]>
1 parent e1a921f commit bc76f57

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,8 +1863,10 @@ static int __init amd_pstate_init(void)
18631863
}
18641864

18651865
ret = cpufreq_register_driver(current_pstate_driver);
1866-
if (ret)
1866+
if (ret) {
18671867
pr_err("failed to register with return %d\n", ret);
1868+
goto disable_driver;
1869+
}
18681870

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

18811883
global_attr_free:
18821884
cpufreq_unregister_driver(current_pstate_driver);
1885+
disable_driver:
1886+
amd_pstate_enable(false);
18831887
return ret;
18841888
}
18851889
device_initcall(amd_pstate_init);

0 commit comments

Comments
 (0)