From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965656AbbJ0RpH (ORCPT ); Tue, 27 Oct 2015 13:45:07 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:34153 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965551AbbJ0RdQ (ORCPT ); Tue, 27 Oct 2015 13:33:16 -0400 From: =?UTF-8?q?B=C3=A1lint=20Czobor?= To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Lianwei Wang , =?UTF-8?q?B=C3=A1lint=20Czobor?= Subject: [PATCH 50/70] cpufreq: interactive: fix race on cpufreq TRANSITION notifier Date: Tue, 27 Oct 2015 18:30:38 +0100 Message-Id: <1445967059-6897-50-git-send-email-czoborbalint@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1445967059-6897-1-git-send-email-czoborbalint@gmail.com> References: <1445967059-6897-1-git-send-email-czoborbalint@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lianwei Wang 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 Signed-off-by: Bálint Czobor --- drivers/cpufreq/cpufreq_interactive.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index 7303f50..691923d 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); -- 1.7.9.5