diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2014-06-18 14:27:32 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-06-18 15:52:20 -0400 |
commit | fefa8ff810c5ab4c4206aed9d159c4d6fe8d4f1c (patch) | |
tree | 6118b6695bc29d4bad0a0cdb36ee295903574711 /drivers/cpufreq/cpufreq.c | |
parent | 51d211e9c334b9eca3505f4052afa660c3e0606b (diff) |
cpufreq: unlock when failing cpufreq_update_policy()
Commit bd0fa9bb455d 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: bd0fa9bb455d ("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>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index aed2b0cb83dc..62259d27f03e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -2242,10 +2242,8 @@ int cpufreq_update_policy(unsigned int cpu) | |||
2242 | struct cpufreq_policy new_policy; | 2242 | struct cpufreq_policy new_policy; |
2243 | int ret; | 2243 | int ret; |
2244 | 2244 | ||
2245 | if (!policy) { | 2245 | if (!policy) |
2246 | ret = -ENODEV; | 2246 | return -ENODEV; |
2247 | goto no_policy; | ||
2248 | } | ||
2249 | 2247 | ||
2250 | down_write(&policy->rwsem); | 2248 | down_write(&policy->rwsem); |
2251 | 2249 | ||
@@ -2264,7 +2262,7 @@ int cpufreq_update_policy(unsigned int cpu) | |||
2264 | new_policy.cur = cpufreq_driver->get(cpu); | 2262 | new_policy.cur = cpufreq_driver->get(cpu); |
2265 | if (WARN_ON(!new_policy.cur)) { | 2263 | if (WARN_ON(!new_policy.cur)) { |
2266 | ret = -EIO; | 2264 | ret = -EIO; |
2267 | goto no_policy; | 2265 | goto unlock; |
2268 | } | 2266 | } |
2269 | 2267 | ||
2270 | if (!policy->cur) { | 2268 | if (!policy->cur) { |
@@ -2279,10 +2277,10 @@ int cpufreq_update_policy(unsigned int cpu) | |||
2279 | 2277 | ||
2280 | ret = cpufreq_set_policy(policy, &new_policy); | 2278 | ret = cpufreq_set_policy(policy, &new_policy); |
2281 | 2279 | ||
2280 | unlock: | ||
2282 | up_write(&policy->rwsem); | 2281 | up_write(&policy->rwsem); |
2283 | 2282 | ||
2284 | cpufreq_cpu_put(policy); | 2283 | cpufreq_cpu_put(policy); |
2285 | no_policy: | ||
2286 | return ret; | 2284 | return ret; |
2287 | } | 2285 | } |
2288 | EXPORT_SYMBOL(cpufreq_update_policy); | 2286 | EXPORT_SYMBOL(cpufreq_update_policy); |