[PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails

Mario Limonciello posted 1 patch 1 year, 5 months ago
drivers/cpufreq/amd-pstate.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails
Posted by Mario Limonciello 1 year, 5 months ago
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
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
Cc: Peter Jung <peterjung1337@gmail.com>
 drivers/cpufreq/amd-pstate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 05e80d2f8803..7195dfa98cc5 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -2030,8 +2030,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) {
@@ -2047,6 +2049,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);
-- 
2.43.0
Re: [PATCH] cpufreq: amd-pstate: Don't create attributes when registration fails
Posted by Gautham R.Shenoy 1 year, 5 months ago
Mario Limonciello <mario.limonciello@amd.com> writes:

> 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
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Thanks for fixing this.

Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>

> ---
> Cc: Peter Jung <peterjung1337@gmail.com>
>  drivers/cpufreq/amd-pstate.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 05e80d2f8803..7195dfa98cc5 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -2030,8 +2030,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) {
> @@ -2047,6 +2049,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);
> -- 
> 2.43.0