Message ID | b75219c6511ff0cf9a4c9c7603091286b803ae22.1493115651.git.viresh.kumar@linaro.org |
---|---|
State | Accepted |
Commit | 289d72afddf83440117c35d864bf0c6309c1d011 |
Headers | show |
Series | [V4,01/17] thermal: cpu_cooling: Avoid accessing potentially freed structures | expand |
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 69d0f430b2d1..be29489dd247 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -153,8 +153,10 @@ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) mutex_lock(&cooling_list_lock); list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) { if (cpumask_test_cpu(cpu, &cpufreq_dev->allowed_cpus)) { + unsigned long level = get_level(cpufreq_dev, freq); + mutex_unlock(&cooling_list_lock); - return get_level(cpufreq_dev, freq); + return level; } } mutex_unlock(&cooling_list_lock);