cpufreq: scmi: Fix possible null pointer dereference
Subsystems (2)
PATCH 1/1 cpufreq: scmi: Fix possible null pointer dereference
Check if policy is NULL before dereferencing it.
This is similar to the commit cf7de25878a1 ("cppc_cpufreq: Fix possible null pointer dereference").
This is found by our static analysis tool KNighter.
--- drivers/cpufreq/scmi-cpufreq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/cpufreq/scmi-cpufreq.c +5 -1
@@ -38,10 +38,14 @@ static struct cpufreq_driver scmi_cpufreq_driver;static unsigned int scmi_cpufreq_get_rate (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_get_raw (cpu); -struct scmi_data *priv = policy->driver_data; +struct scmi_data *priv;unsigned long rate;int ret; +if (!policy) +return 0 ; + priv = policy->driver_data; + ret = perf_ops->freq_get (ph, priv->domain_id, &rate, false);if (ret)return 0 ;
Signature · 1 line
2.34.1
Quoted 9 lines · Chenyuan Yang
Check if policy is NULL before dereferencing it.
This is similar to the commit
cf7de25878a1("cppc_cpufreq: Fix possible null pointer dereference").This is found by our static analysis tool KNighter.
Signed-off-by Chenyuan Yang <[email protected]>Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI message protocol")
Henry Martin already fixed this in commit 484d3f15cc6c ("cpufreq: scmi:
Fix null-ptr-deref in scmi_cpufreq_get_rate()").
regards,
dan carpenter
Quoted 7 lines · Dan Carpenter
Quoted 5 lines · Chenyuan Yang
Check if policy is NULL before dereferencing it.
This is similar to the commit
cf7de25878a1("cppc_cpufreq: Fix possible null pointer dereference").
Quoted 7 lines
Quoted 4 lines
This is found by our static analysis tool KNighter.
Signed-off-by Chenyuan Yang <[email protected]>Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI message protocol")Henry Martin already fixed this in commit
484d3f15cc6c("cpufreq: scmi:
Fix null-ptr-deref inscmi_cpufreq_get_rate()").
Thanks so much for pointing this out!
It is good to hear that there is already a fix.
Quoted 2 lines
regards,
dan carpenter
-Chenyuan