Skip to content

Commit fefa8ff

Browse files
aaronp24rafaeljw
authored andcommitted
cpufreq: unlock when failing cpufreq_update_policy()
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 <aplattner@nvidia.com> Cc: 3.15+ <stable@vger.kernel.org> # 3.15+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 51d211e commit fefa8ff

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎drivers/cpufreq/cpufreq.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,10 +2242,8 @@ int cpufreq_update_policy(unsigned int cpu)
22422242
struct cpufreq_policy new_policy;
22432243
int ret;
22442244

2245-
if (!policy) {
2246-
ret = -ENODEV;
2247-
goto no_policy;
2248-
}
2245+
if (!policy)
2246+
return -ENODEV;
22492247

22502248
down_write(&policy->rwsem);
22512249

@@ -2264,7 +2262,7 @@ int cpufreq_update_policy(unsigned int cpu)
22642262
new_policy.cur = cpufreq_driver->get(cpu);
22652263
if (WARN_ON(!new_policy.cur)) {
22662264
ret = -EIO;
2267-
goto no_policy;
2265+
goto unlock;
22682266
}
22692267

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

22802278
ret = cpufreq_set_policy(policy, &new_policy);
22812279

2280+
unlock:
22822281
up_write(&policy->rwsem);
22832282

22842283
cpufreq_cpu_put(policy);
2285-
no_policy:
22862284
return ret;
22872285
}
22882286
EXPORT_SYMBOL(cpufreq_update_policy);

0 commit comments

Comments
 (0)