Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc8229cf authored by Lianwei Wang's avatar Lianwei Wang Committed by Amit Pundir
Browse files

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: default avatarLianwei Wang <a22439@motorola.com>
parent dd7886b8
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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);