lkml.org 
[lkml]   [2016]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 14/19] cpufreq: fix locking of policy->rwsem in cpufreq_offline_finish
Date
There are paths in cpufreq_offline_prepare where policy is used, but its
rwsem is not held.

Fix it.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
---
drivers/cpufreq/cpufreq.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 91158b0..ba452c3 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1381,9 +1381,13 @@ static void cpufreq_offline_finish(unsigned int cpu)
return;
}

+ down_write(&policy->rwsem);
+
/* Only proceed for inactive policies */
- if (!policy_is_inactive(policy))
+ if (!policy_is_inactive(policy)) {
+ up_write(&policy->rwsem);
return;
+ }

/* If cpu is last user of policy, free policy */
if (has_target()) {
@@ -1392,6 +1396,8 @@ static void cpufreq_offline_finish(unsigned int cpu)
pr_err("%s: Failed to exit governor\n", __func__);
}

+ up_write(&policy->rwsem);
+
/*
* Perform the ->exit() even during light-weight tear-down,
* since this is a core component, and is essential for the
--
2.2.2
\
 
 \ /
  Last update: 2016-01-11 19:21    [W:0.471 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site