From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761521AbcAKRkR (ORCPT ); Mon, 11 Jan 2016 12:40:17 -0500 Received: from foss.arm.com ([217.140.101.70]:57248 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761161AbcAKRha (ORCPT ); Mon, 11 Jan 2016 12:37:30 -0500 From: Juri Lelli To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, peterz@infradead.org, rjw@rjwysocki.net, viresh.kumar@linaro.org, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, juri.lelli@arm.com Subject: [RFC PATCH 09/19] cpufreq: fix warning for show_scaling_available_governors unlocked access to cpufreq_governor_list Date: Mon, 11 Jan 2016 17:35:50 +0000 Message-Id: <1452533760-13787-10-git-send-email-juri.lelli@arm.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1452533760-13787-1-git-send-email-juri.lelli@arm.com> References: <1452533760-13787-1-git-send-email-juri.lelli@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org show_scaling_available_governors iterates through cpufreq_governor_list without holding cpufreq_governor_mutex; this generates the following warning: [ 700.910381] ------------[ cut here ]------------ [ 700.924282] WARNING: CPU: 2 PID: 1756 at kernel/drivers/cpufreq/cpufreq.c:700 show_scaling_available_governors+0x6f/0xb8() [ 700.965473] Modules linked in: [ 700.974637] CPU: 2 PID: 1756 Comm: cat Tainted: G W 4.4.0-rc2+ #299 [ 700.996813] Hardware name: ARM-Versatile Express [ 701.010674] [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [ 701.033905] [] (show_stack) from [] (dump_stack+0x55/0x78) [ 701.055561] [] (dump_stack) from [] (warn_slowpath_common+0x59/0x84) [ 701.079839] [] (warn_slowpath_common) from [] (warn_slowpath_null+0x17/0x1c) [ 701.106182] [] (warn_slowpath_null) from [] (show_scaling_available_governors+0x6f/0xb8) [ 701.135656] [] (show_scaling_available_governors) from [] (show+0x27/0x38) [ 701.161488] [] (show) from [] (sysfs_kf_seq_show+0x5f/0xa0) [ 701.183409] [] (sysfs_kf_seq_show) from [] (kernfs_seq_show+0x1b/0x1c) [ 701.208188] [] (kernfs_seq_show) from [] (seq_read+0x129/0x33c) [ 701.231161] [] (seq_read) from [] (__vfs_read+0x1b/0x84) [ 701.252300] [] (__vfs_read) from [] (vfs_read+0x5f/0xb0) [ 701.273436] [] (vfs_read) from [] (SyS_read+0x39/0x68) [ 701.294049] [] (SyS_read) from [] (ret_fast_syscall+0x1/0x1a) [ 701.316484] ---[ end trace 5dd15744a4da127c ]--- Fix this by locking cpufreq_governor_mutex before for_each_governor(). Cc: "Rafael J. Wysocki" Cc: Viresh Kumar Signed-off-by: Juri Lelli --- drivers/cpufreq/cpufreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d065435..d91fdb8 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -694,7 +694,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, goto out; } - lockdep_assert_held(&cpufreq_governor_mutex); + mutex_lock(&cpufreq_governor_mutex); for_each_governor(t) { if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) - (CPUFREQ_NAME_LEN + 2))) @@ -702,6 +702,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, i += scnprintf(&buf[i], CPUFREQ_NAME_PLEN, "%s ", t->name); } out: + mutex_unlock(&cpufreq_governor_mutex); i += sprintf(&buf[i], "\n"); return i; } -- 2.2.2