Commit fefa8ff8 authored by Aaron Plattner's avatar Aaron Plattner Committed by Rafael J. Wysocki

cpufreq: unlock when failing cpufreq_update_policy()

Commit bd0fa9bb 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: bd0fa9bb ("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: default avatarAaron Plattner <aplattner@nvidia.com>
Cc: 3.15+ <stable@vger.kernel.org> # 3.15+
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 51d211e9
...@@ -2242,10 +2242,8 @@ int cpufreq_update_policy(unsigned int cpu) ...@@ -2242,10 +2242,8 @@ int cpufreq_update_policy(unsigned int cpu)
struct cpufreq_policy new_policy; struct cpufreq_policy new_policy;
int ret; int ret;
if (!policy) { if (!policy)
ret = -ENODEV; return -ENODEV;
goto no_policy;
}
down_write(&policy->rwsem); down_write(&policy->rwsem);
...@@ -2264,7 +2262,7 @@ int cpufreq_update_policy(unsigned int cpu) ...@@ -2264,7 +2262,7 @@ int cpufreq_update_policy(unsigned int cpu)
new_policy.cur = cpufreq_driver->get(cpu); new_policy.cur = cpufreq_driver->get(cpu);
if (WARN_ON(!new_policy.cur)) { if (WARN_ON(!new_policy.cur)) {
ret = -EIO; ret = -EIO;
goto no_policy; goto unlock;
} }
if (!policy->cur) { if (!policy->cur) {
...@@ -2279,10 +2277,10 @@ int cpufreq_update_policy(unsigned int cpu) ...@@ -2279,10 +2277,10 @@ int cpufreq_update_policy(unsigned int cpu)
ret = cpufreq_set_policy(policy, &new_policy); ret = cpufreq_set_policy(policy, &new_policy);
unlock:
up_write(&policy->rwsem); up_write(&policy->rwsem);
cpufreq_cpu_put(policy); cpufreq_cpu_put(policy);
no_policy:
return ret; return ret;
} }
EXPORT_SYMBOL(cpufreq_update_policy); EXPORT_SYMBOL(cpufreq_update_policy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment