From: Mario Limonciello Date: Sun, 23 Jun 2024 20:09:18 +0000 (-0500) Subject: cpufreq: amd-pstate: Don't create attributes when registration fails X-Git-Tag: v6.11-rc1~173^2~2^2^2~7^2~1^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc76f57574741cc8e7d04c53f199d8722ce09413;p=thirdparty%2Fkernel%2Flinux.git 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: alex.s.cochran@proton.me Reviewed-by: Gautham R. Shenoy Reviewed-by: Perry Yuan Link: https://lore.kernel.org/r/20240623200918.52104-1-mario.limonciello@amd.com Signed-off-by: Mario Limonciello --- diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index c418f2bb5cede..afcf398574f61 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -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) { @@ -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);