Re: [PATCH 6.6.y] cpufreq: amd-pstate: add check for cpufreq_cpu_get's return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, please discard this patch, I saw someone already sent it.

- Raj

> Sent: Thursday, January 23, 2025 at 3:49 PM
> From: "Rajani kantha" <rajanikantha@xxxxxxxxxxxx>
> To: abelova@xxxxxxxxxxxxx, perry.yuan@xxxxxxx, viresh.kumar@xxxxxxxxxx, stable@xxxxxxxxxxxxxxx
> Subject: [PATCH 6.6.y] cpufreq: amd-pstate: add check for cpufreq_cpu_get's return value
>
> From: Anastasia Belova <abelova@xxxxxxxxxxxxx>
>
> [ upstream commit 5493f9714e4cdaf0ee7cec15899a231400cb1a9f ]
>
> cpufreq_cpu_get may return NULL. To avoid NULL-dereference check it
> and return in case of error.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Anastasia Belova <abelova@xxxxxxxxxxxxx>
> Reviewed-by: Perry Yuan <perry.yuan@xxxxxxx>
> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> <Raj: on 6.6, there don't have function amd_pstate_update_limits()
> so applied the NULL checking in amd_pstate_adjust_perf() only>
> Signed-off-by: Rajani Kantha <rajanikantha@xxxxxxxxxxxx>
> ---
>  drivers/cpufreq/amd-pstate.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index cdead37d0823..a64baa97e358 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -579,8 +579,13 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
>  	unsigned long max_perf, min_perf, des_perf,
>  		      cap_perf, lowest_nonlinear_perf, max_freq;
>  	struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
> -	struct amd_cpudata *cpudata = policy->driver_data;
>  	unsigned int target_freq;
> +	struct amd_cpudata *cpudata;
> +
> +	if (!policy)
> +		return;
> +
> +	cpudata = policy->driver_data;
>
>  	if (policy->min != cpudata->min_limit_freq || policy->max != cpudata->max_limit_freq)
>  		amd_pstate_update_min_max_limit(policy);
> --
> 2.35.3
>
>
>





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux