diff options
author | Lianwei Wang <a22439@motorola.com> | 2013-05-16 12:07:23 +0800 |
---|---|---|
committer | Arve Hjønnevåg <arve@android.com> | 2013-07-01 15:46:28 -0700 |
commit | e1fb7646f1092a0e9baa0007983563092f3ab93d (patch) | |
tree | 15e2dac581951ef10dfe815428a4d1f1ec948dea /drivers/cpufreq | |
parent | 1dc1499a432260fd9ea4b43726870d31efbf7042 (diff) |
cpufreq: interactive: fix race on cpufreq TRANSITION notifier
The cpufreq TRANSTION notifier callback does not check the
governor_enabled state on affected CPUS, which will case
kernel panic in update_load because the policy object maybe
NULL or invalid when governor_enabled is false.
Change-Id: Ie0f1718124f61e2f9b5da57abc6981ada5b83908
Signed-off-by: Lianwei Wang <a22439@motorola.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq_interactive.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index 7303f50a1180..691923d6c868 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -634,9 +634,19 @@ static int cpufreq_interactive_notifier( for_each_cpu(cpu, pcpu->policy->cpus) { struct cpufreq_interactive_cpuinfo *pjcpu = &per_cpu(cpuinfo, cpu); + if (cpu != freq->cpu) { + if (!down_read_trylock(&pjcpu->enable_sem)) + continue; + if (!pjcpu->governor_enabled) { + up_read(&pjcpu->enable_sem); + continue; + } + } spin_lock_irqsave(&pjcpu->load_lock, flags); update_load(cpu); spin_unlock_irqrestore(&pjcpu->load_lock, flags); + if (cpu != freq->cpu) + up_read(&pjcpu->enable_sem); } up_read(&pcpu->enable_sem); |