From: Mario Limonciello <mario.limonciello@amd.com>
To: Anastasia Belova <abelova@astralinux.ru>, Huang Rui <ray.huang@amd.com>
Cc: "Gautham R. Shenoy" <gautham.shenoy@amd.com>,
Perry Yuan <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,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] cpufreq: amd-pstate: add check for cpufreq_cpu_get's return value
Date: Tue, 4 Jun 2024 10:56:40 -0500 [thread overview]
Message-ID: <5b4155c9-35d4-499e-9256-148b3ed7a491@amd.com> (raw)
In-Reply-To: <20240603110741.24818-1-abelova@astralinux.ru>
On 6/3/2024 06:07, Anastasia Belova wrote:
> 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@astralinux.ru>
Thank you!
Acked-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/cpufreq/amd-pstate.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 1b7e82a0ad2e..672cb6c280a4 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -621,6 +621,8 @@ 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);
> + if (!policy)
> + return;
> struct amd_cpudata *cpudata = policy->driver_data;
> unsigned int target_freq;
>
> @@ -777,6 +779,8 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata)
> static void amd_pstate_update_limits(unsigned int cpu)
> {
> struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
> + if (!policy)
> + return;
> struct amd_cpudata *cpudata = policy->driver_data;
> u32 prev_high = 0, cur_high = 0;
> int ret;
next prev parent reply other threads:[~2024-06-04 15:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-03 11:07 [PATCH] cpufreq: amd-pstate: add check for cpufreq_cpu_get's return value Anastasia Belova
2024-06-04 15:56 ` Mario Limonciello [this message]
2024-06-06 9:55 ` Gautham R. Shenoy
2024-08-08 13:07 ` Anastasia Belova
2024-08-23 16:19 ` Mario Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5b4155c9-35d4-499e-9256-148b3ed7a491@amd.com \
--to=mario.limonciello@amd.com \
--cc=abelova@astralinux.ru \
--cc=gautham.shenoy@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=perry.yuan@amd.com \
--cc=rafael@kernel.org \
--cc=ray.huang@amd.com \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox