aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang Bo <bo.zhang@nxp.com>2017-06-01 14:21:58 +0800
committerAmit Pundir <amit.pundir@linaro.org>2017-07-17 10:27:40 +0530
commit85e5f384341dbfebfeff532d46151bda761edaec (patch)
treeeedd1c7b0e18b9b3c8c1476e5e113e7571599e11
parent311e62c3bde7ae4381ecb1cca415c897b52268a5 (diff)
downloadlinaro-android-85e5f384341dbfebfeff532d46151bda761edaec.tar.gz
ANDROID: cpufreq: system panic when switch interactive governor frequently
When try to suspend and resume and playback video or audio at the same time, Power HAL will switch governor between conservative and interactive. Before cpufreq switch to conservative governor, it will stop interactive governor(in function: cpufreq_interactive_stop) and set "icpu->ipolicy = NULL;". If the cpufreq_interactive_speedchange_task doesn't exit and run at the same time, it try to get "policy = icpu->ipolicy->policy;". It will cause system panic. Need to check pointer validatation before read. Change-Id: I608969370738130c44b1816f073423d509a3bcd7 Signed-off-by: Zhang Bo <bo.zhang@nxp.com> Signed-off-by: Todd Poynor <toddpoynor@google.com>
-rw-r--r--drivers/cpufreq/cpufreq_interactive.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
index d6cac0e8e7a6..576be554d83d 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -570,13 +570,15 @@ again:
for_each_cpu(cpu, &tmp_mask) {
struct interactive_cpu *icpu = &per_cpu(interactive_cpu, cpu);
- struct cpufreq_policy *policy = icpu->ipolicy->policy;
+ struct cpufreq_policy *policy;
if (unlikely(!down_read_trylock(&icpu->enable_sem)))
continue;
- if (likely(icpu->ipolicy))
+ if (likely(icpu->ipolicy)) {
+ policy = icpu->ipolicy->policy;
cpufreq_interactive_adjust_cpu(cpu, policy);
+ }
up_read(&icpu->enable_sem);
}