From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f65.google.com ([74.125.83.65]:35118 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935393AbdEXCmK (ORCPT ); Tue, 23 May 2017 22:42:10 -0400 Received: by mail-pg0-f65.google.com with SMTP id i63so15349303pgd.2 for ; Tue, 23 May 2017 19:42:10 -0700 (PDT) Subject: patch "thermal: cpu_cooling: Avoid accessing potentially freed structures" added to thermal-soc tree To: viresh.kumar@linaro.org, edubezval@gmail.com, lukasz.luba@arm.com, stable@vger.kernel.org Cc: Zhang Rui From: Eduardo Valentin Date: Tue, 23 May 2017 19:38:19 -0700 Message-ID: <1495593499279@besouro> Sender: stable-owner@vger.kernel.org List-ID: This is a simple automated notification to let you know that I've just added the patch titled thermal: cpu_cooling: Avoid accessing potentially freed structures to my thermal-soc git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git in the linus branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will also be merged in the next major kernel release during the merge window. If you have any questions about this process, please let me know. All the best, Eduardo Valentin ---------- >>From 2e5103b6131932cad8f6bfc28c1940bd3c2b9ca9 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Tue, 25 Apr 2017 15:57:08 +0530 Subject: thermal: cpu_cooling: Avoid accessing potentially freed structures After the lock is dropped, it is possible that the cpufreq_dev gets freed before we call get_level() and that can cause kernel to crash. Drop the lock after we are done using the structure. Cc: 4.2+ # 4.2+ Fixes: 02373d7c69b4 ("thermal: cpu_cooling: fix lockdep problems in cpu_cooling") Signed-off-by: Viresh Kumar Tested-by: Lukasz Luba Signed-off-by: Eduardo Valentin --- drivers/thermal/cpu_cooling.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 69d0f43..be29489 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); -- 2.1.4