Skip to content

Commit

Permalink
cpufreq: unlock when failing cpufreq_update_policy()
Browse files Browse the repository at this point in the history
Commit bd0fa9b introduced a failure path to cpufreq_update_policy() if
cpufreq_driver->get(cpu) returns NULL.  However, it jumps to the 'no_policy'
label, which exits without unlocking any of the locks the function acquired
earlier.  This causes later calls into cpufreq to hang.

Fix this by creating a new 'unlock' label and jumping to that instead.

Fixes: bd0fa9b ("cpufreq: Return error if ->get() failed in cpufreq_update_policy()")
Link: https://devtalk.nvidia.com/default/topic/751903/kernel-3-15-and-nv-drivers-337-340-failed-to-initialize-the-nvidia-kernel-module-gtx-550-ti-/
Signed-off-by: Aaron Plattner <[email protected]>
Cc: 3.15+ <[email protected]> # 3.15+
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
aaronp24 authored and rafaeljw committed Jun 18, 2014
1 parent 51d211e commit fefa8ff
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -2242,10 +2242,8 @@ int cpufreq_update_policy(unsigned int cpu)
struct cpufreq_policy new_policy;
int ret;

if (!policy) {
ret = -ENODEV;
goto no_policy;
}
if (!policy)
return -ENODEV;

down_write(&policy->rwsem);

Expand All @@ -2264,7 +2262,7 @@ int cpufreq_update_policy(unsigned int cpu)
new_policy.cur = cpufreq_driver->get(cpu);
if (WARN_ON(!new_policy.cur)) {
ret = -EIO;
goto no_policy;
goto unlock;
}

if (!policy->cur) {
Expand All @@ -2279,10 +2277,10 @@ int cpufreq_update_policy(unsigned int cpu)

ret = cpufreq_set_policy(policy, &new_policy);

unlock:
up_write(&policy->rwsem);

cpufreq_cpu_put(policy);
no_policy:
return ret;
}
EXPORT_SYMBOL(cpufreq_update_policy);
Expand Down

0 comments on commit fefa8ff

Please sign in to comment.