[<prev] [next>] [day] [month] [year] [list]
Message-ID: <b6ebf19c-8328-44de-a695-157061a9d8a8@omp.ru>
Date: Fri, 12 Sep 2025 23:35:07 +0300
From: Sergey Shtylyov <s.shtylyov@....ru>
To: <stable@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: Henry Martin <bsdhenrymartin@...il.com>, Sudeep Holla
<sudeep.holla@....com>, Viresh Kumar <viresh.kumar@...aro.org>,
<lvc-project@...uxtesting.org>
Subject: [PATCH 5.10.y] cpufreq: scmi: Fix null-ptr-deref in
scmi_cpufreq_get_rate()
From: Henry Martin <bsdhenrymartin@...il.com>
[ Upstream commit 484d3f15cc6cbaa52541d6259778e715b2c83c54 ]
cpufreq_cpu_get_raw() can return NULL when the target CPU is not present
in the policy->cpus mask. scmi_cpufreq_get_rate() does not check for
this case, which results in a NULL pointer dereference.
Add NULL check after cpufreq_cpu_get_raw() to prevent this issue.
[Sergey: resolved reject (reordering the local variables).]
Fixes: 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI message protocol")
Signed-off-by: Henry Martin <bsdhenrymartin@...il.com>
Acked-by: Sudeep Holla <sudeep.holla@....com>
Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
Signed-off-by: Sergey Shtylyov <s.shtylyov@....ru>
---
drivers/cpufreq/scmi-cpufreq.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
Index: linux-stable/drivers/cpufreq/scmi-cpufreq.c
===================================================================
--- linux-stable.orig/drivers/cpufreq/scmi-cpufreq.c
+++ linux-stable/drivers/cpufreq/scmi-cpufreq.c
@@ -29,12 +29,18 @@ static const struct scmi_handle *handle;
static unsigned int scmi_cpufreq_get_rate(unsigned int cpu)
{
- struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
const struct scmi_perf_ops *perf_ops = handle->perf_ops;
- struct scmi_data *priv = policy->driver_data;
+ struct cpufreq_policy *policy;
+ struct scmi_data *priv;
unsigned long rate;
int ret;
+ policy = cpufreq_cpu_get_raw(cpu);
+ if (unlikely(!policy))
+ return 0;
+
+ priv = policy->driver_data;
+
ret = perf_ops->freq_get(handle, priv->domain_id, &rate, false);
if (ret)
return 0;
Powered by blists - more mailing lists