Message ID | 1578228650-17157-1-git-send-email-qiwuchen55@gmail.com |
---|---|
State | New |
Headers | show |
Series | [v2] cpufreq: brcmstb-avs-cpufreq: avoid potential stuck and UAF risk | expand |
diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c index 77b0e5d..6d2bf5c 100644 --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c @@ -452,8 +452,15 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv) static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) { - struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); - struct private_data *priv = policy->driver_data; + struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu); + struct private_data *priv; + + if (!policy) + return 0; + + priv = policy->driver_data; + if (!priv || !priv->base) + return 0; return brcm_avs_get_frequency(priv->base); }