Skip to content

Commit

Permalink
cpufreq: ondemand: Fix locking issue in store_powersave_bias
Browse files Browse the repository at this point in the history
store_powersave_bias takes timer_mutex before calling dbs_timer_exit
which tries to cancel the delayed work do_dbs_timer which in turn
tries to take the same lock. This can cause a lock recursion under
the race condition where can cancel_delayed_work_sync is called
when the work has already started executing.

This can be avoided by taking that lock after calling
dbs_timer_exit.

Change-Id: I7f862286e66f1ddc1e13e4eeee369dd188fc10d5
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
  • Loading branch information
Rohit Gupta authored and hellsgod committed Sep 16, 2013
1 parent cb0af40 commit 7d946ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/cpufreq/cpufreq_ondemand.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,15 @@ static ssize_t store_powersave_bias(struct kobject *a, struct attribute *b,

if (dbs_info->cur_policy) {
/* cpu using ondemand, cancel dbs timer */
mutex_lock(&dbs_info->timer_mutex);
dbs_timer_exit(dbs_info);

mutex_lock(&dbs_info->timer_mutex);
ondemand_powersave_bias_setspeed(
dbs_info->cur_policy,
NULL,
input);

mutex_unlock(&dbs_info->timer_mutex);

}
skip_this_cpu_bypass:
unlock_policy_rwsem_write(cpu);
Expand Down

0 comments on commit 7d946ca

Please sign in to comment.