summaryrefslogtreecommitdiff
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorPuneet Saxena <puneets@nvidia.com>2012-06-07 19:19:59 +0530
committerSimone Willett <swillett@nvidia.com>2012-07-13 14:44:57 -0700
commitca7d8fa1906d2f2a2c311d337a14b328ed13c414 (patch)
treea6b3d5a9dba30b267b12e1deb85d7e8726a0a788 /drivers/cpufreq/cpufreq.c
parentbf0e1f670b1ca8687890abaf7cf24e120a54415c (diff)
cpufreq: Protected access of policy attribute
It takes read RW semaphore to access policy governor bug 997731 Change-Id: Ibdc3dd54cf6076c0fef4bc58f144e4bcb4631d76 Signed-off-by: Puneet Saxena <puneets@nvidia.com> Reviewed-on: http://git-master/r/107079 GVS: Gerrit_Virtual_Submit Reviewed-by: Sang-Hun Lee <sanlee@nvidia.com> Reviewed-by: Peter Boonstoppel <pboonstoppel@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 629806dc5cbf..02e8c9120d6b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1805,13 +1805,27 @@ int cpufreq_set_gov(char *target_gov, unsigned int cpu)
if (!cur_policy)
return -EINVAL;
- new_policy = *cur_policy;
- if (!strncmp(cur_policy->governor->name, target_gov,
- strlen(target_gov))) {
- /* Target governer & current governer is same */
+ if (lock_policy_rwsem_read(cur_policy->cpu) < 0) {
+ ret = -EINVAL;
+ goto err_out;
+ }
+
+ if (cur_policy->governor)
+ ret = strncmp(cur_policy->governor->name, target_gov,
+ strlen(target_gov));
+ else {
+ unlock_policy_rwsem_read(cur_policy->cpu);
+ ret = -EINVAL;
+ goto err_out;
+ }
+ unlock_policy_rwsem_read(cur_policy->cpu);
+
+ if (!ret) {
+ pr_debug(" Target governer & current governer is same\n");
ret = -EINVAL;
goto err_out;
} else {
+ new_policy = *cur_policy;
if (cpufreq_parse_governor(target_gov, &new_policy.policy,
&new_policy.governor)) {
ret = -EINVAL;