]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpufreq: amd-pstate: Don't create attributes when registration fails
authorMario Limonciello <mario.limonciello@amd.com>
Sun, 23 Jun 2024 20:09:18 +0000 (15:09 -0500)
committerMario Limonciello <mario.limonciello@amd.com>
Mon, 24 Jun 2024 18:17:56 +0000 (13:17 -0500)
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>
drivers/cpufreq/amd-pstate.c

index c418f2bb5cede2935bc0204f55b245899ecb0a6b..afcf398574f61d1feb587993f7e15a8568ce0f3c 100644 (file)
@@ -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);