mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpufreq: amd-pstate: Fix uninitialized variable in amd_pstate_cpu_boost_update()
@ 2024-07-18 20:08 Dan Carpenter
  2024-07-19  6:38 ` Yuan, Perry
  2024-07-22  8:55 ` Gautham R. Shenoy
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-07-18 20:08 UTC (permalink / raw)
  To: Perry Yuan
  Cc: Huang Rui, Gautham R. Shenoy, Mario Limonciello, Perry Yuan,
	Rafael J. Wysocki, Viresh Kumar, linux-pm, linux-kernel,
	kernel-janitors

Smatch complains that "ret" could be uninitialized:

  drivers/cpufreq/amd-pstate.c:734 amd_pstate_cpu_boost_update()
  error: uninitialized symbol 'ret'.

This seems like it probably is a real issue.  Initialize "ret" to zero to
be safe.

Fixes: c8c68c38b56f ("cpufreq: amd-pstate: initialize core precision boost state")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/cpufreq/amd-pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 68c616b572f2..358bd88cd0c5 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -692,7 +692,7 @@ static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on)
 	struct amd_cpudata *cpudata = policy->driver_data;
 	struct cppc_perf_ctrls perf_ctrls;
 	u32 highest_perf, nominal_perf, nominal_freq, max_freq;
-	int ret;
+	int ret = 0;
 
 	highest_perf = READ_ONCE(cpudata->highest_perf);
 	nominal_perf = READ_ONCE(cpudata->nominal_perf);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] cpufreq: amd-pstate: Fix uninitialized variable in amd_pstate_cpu_boost_update()
  2024-07-18 20:08 [PATCH] cpufreq: amd-pstate: Fix uninitialized variable in amd_pstate_cpu_boost_update() Dan Carpenter
@ 2024-07-19  6:38 ` Yuan, Perry
  2024-07-22  8:55 ` Gautham R. Shenoy
  1 sibling, 0 replies; 3+ messages in thread
From: Yuan, Perry @ 2024-07-19  6:38 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Huang, Ray, Shenoy, Gautham Ranjal, Limonciello, Mario,
	Rafael J. Wysocki, Viresh Kumar, linux-pm, linux-kernel,
	kernel-janitors

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Dan,

> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: Friday, July 19, 2024 4:09 AM
> To: Yuan, Perry <Perry.Yuan@amd.com>
> Cc: Huang, Ray <Ray.Huang@amd.com>; Shenoy, Gautham Ranjal
> <gautham.shenoy@amd.com>; Limonciello, Mario
> <Mario.Limonciello@amd.com>; Yuan, Perry <Perry.Yuan@amd.com>; Rafael
> J. Wysocki <rafael@kernel.org>; Viresh Kumar <viresh.kumar@linaro.org>;
> linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org; kernel-
> janitors@vger.kernel.org
> Subject: [PATCH] cpufreq: amd-pstate: Fix uninitialized variable in
> amd_pstate_cpu_boost_update()
>
> Smatch complains that "ret" could be uninitialized:
>
>   drivers/cpufreq/amd-pstate.c:734 amd_pstate_cpu_boost_update()
>   error: uninitialized symbol 'ret'.
>
> This seems like it probably is a real issue.  Initialize "ret" to zero to be safe.
>
> Fixes: c8c68c38b56f ("cpufreq: amd-pstate: initialize core precision boost
> state")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/cpufreq/amd-pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 68c616b572f2..358bd88cd0c5 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -692,7 +692,7 @@ static int amd_pstate_cpu_boost_update(struct
> cpufreq_policy *policy, bool on)
>       struct amd_cpudata *cpudata = policy->driver_data;
>       struct cppc_perf_ctrls perf_ctrls;
>       u32 highest_perf, nominal_perf, nominal_freq, max_freq;
> -     int ret;
> +     int ret = 0;
>
>       highest_perf = READ_ONCE(cpudata->highest_perf);
>       nominal_perf = READ_ONCE(cpudata->nominal_perf);
> --
> 2.43.0

Thanks for the fix.
LGTM
Reviewed-by: Perry Yuan <perry.yuan@amd.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufreq: amd-pstate: Fix uninitialized variable in amd_pstate_cpu_boost_update()
  2024-07-18 20:08 [PATCH] cpufreq: amd-pstate: Fix uninitialized variable in amd_pstate_cpu_boost_update() Dan Carpenter
  2024-07-19  6:38 ` Yuan, Perry
@ 2024-07-22  8:55 ` Gautham R. Shenoy
  1 sibling, 0 replies; 3+ messages in thread
From: Gautham R. Shenoy @ 2024-07-22  8:55 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Perry Yuan, Huang Rui, Mario Limonciello, Rafael J. Wysocki,
	Viresh Kumar, linux-pm, linux-kernel, kernel-janitors

Hello Dan,


On Thu, Jul 18, 2024 at 03:08:36PM -0500, Dan Carpenter wrote:
> Smatch complains that "ret" could be uninitialized:
> 
>   drivers/cpufreq/amd-pstate.c:734 amd_pstate_cpu_boost_update()
>   error: uninitialized symbol 'ret'.
> 
> This seems like it probably is a real issue.  Initialize "ret" to zero to
> be safe.


Thanks for catching this. Yes, it is a real issue on MSR based
platforms when the amd-pstate driver is not in the passive mode.

> 
> Fixes: c8c68c38b56f ("cpufreq: amd-pstate: initialize core precision boost state")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

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


> ---
>  drivers/cpufreq/amd-pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 68c616b572f2..358bd88cd0c5 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -692,7 +692,7 @@ static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on)
>  	struct amd_cpudata *cpudata = policy->driver_data;
>  	struct cppc_perf_ctrls perf_ctrls;
>  	u32 highest_perf, nominal_perf, nominal_freq, max_freq;
> -	int ret;
> +	int ret = 0;
>  
>  	highest_perf = READ_ONCE(cpudata->highest_perf);
>  	nominal_perf = READ_ONCE(cpudata->nominal_perf);
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-22  8:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-18 20:08 [PATCH] cpufreq: amd-pstate: Fix uninitialized variable in amd_pstate_cpu_boost_update() Dan Carpenter
2024-07-19  6:38 ` Yuan, Perry
2024-07-22  8:55 ` Gautham R. Shenoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®