cpufreq: apple-soc: Fix null-ptr-deref in apple_soc_cpufreq_get_rate()
Subsystems (2)
PATCH v2 1/1 cpufreq: apple-soc: Fix null-ptr-deref in apple_soc_cpufreq_get_rate()
cpufreq_cpu_get_raw() can return NULL when the target CPU is not present in the policy->cpus mask. apple_soc_cpufreq_get_rate() does not check for this case, which results in a NULL pointer dereference.
Fixes 6286bbb40576 ("cpufreq: apple-soc: Add new driver to control Apple SoC CPU P-states")
Signed-off-by Henry Martin <[email protected]>
---
V1 -> V2: Use if (unlikely(!policy)) instead of if (!policy)
drivers/cpufreq/apple-soc-cpufreq.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/cpufreq/apple-soc-cpufreq.c +8 -2
@@ -134,11 +134,17 @@ static const struct of_device_id apple_soc_cpufreq_of_match[] __maybe_unused = {static unsigned int apple_soc_cpufreq_get_rate (unsigned int cpu) { -struct cpufreq_policy *policy =cpufreq_cpu_get_raw (cpu); -struct apple_cpu_priv *priv = policy->driver_data; +struct cpufreq_policy *policy; +struct apple_cpu_priv *priv;struct cpufreq_frequency_table *p;unsigned int pstate; + policy =cpufreq_cpu_get_raw (cpu); +if (unlikely (!policy)) +return 0 ; + + priv = policy->driver_data; +if (priv->info->cur_pstate_mask) {u32 reg =readl_relaxed (priv->reg_base +APPLE_DVFS_STATUS );
Signature · 1 line
2.34.1
Quoted 11 lines · Henry Martin
cpufreq_cpu_get_raw()can return NULL when the target CPU is not present in thepolicy->cpusmask.apple_soc_cpufreq_get_rate()does not check for this case, which results in a NULL pointer dereference.Fixes 6286bbb40576 ("cpufreq: apple-soc: Add new driver to control Apple SoC CPU P-states")Signed-off-by Henry Martin <[email protected]>---
V1 -> V2: Useif (unlikely(!policy))instead ofif (!policy)drivers/cpufreq/apple-soc-cpufreq.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Applied. Thanks.
Signature · 1 line
viresh