76bd795c004afb043e2e6e74100e969efdcea48b
[openwrt/staging/blogic.git] /
1 From 6a1bd7cf4ed7a1948f564aaf16d34b7352c0029b Mon Sep 17 00:00:00 2001
2 From: Wan Jiabing <wanjiabing@vivo.com>
3 Date: Tue, 10 May 2022 17:05:31 +0800
4 Subject: [PATCH 12/21] cpufreq: mediatek: Fix potential deadlock problem in
5 mtk_cpufreq_set_target
6
7 Fix following coccichek error:
8 ./drivers/cpufreq/mediatek-cpufreq.c:199:2-8: preceding lock on line
9 ./drivers/cpufreq/mediatek-cpufreq.c:208:2-8: preceding lock on line
10
11 mutex_lock is acquired but not released before return.
12 Use 'goto out' to help releasing the mutex_lock.
13
14 Fixes: c210063b40ac ("cpufreq: mediatek: Add opp notification support")
15 Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
16 Reviewed-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
17 Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
18 ---
19 drivers/cpufreq/mediatek-cpufreq.c | 6 ++++--
20 1 file changed, 4 insertions(+), 2 deletions(-)
21
22 --- a/drivers/cpufreq/mediatek-cpufreq.c
23 +++ b/drivers/cpufreq/mediatek-cpufreq.c
24 @@ -196,7 +196,8 @@ static int mtk_cpufreq_set_target(struct
25
26 if (pre_vproc < 0) {
27 dev_err(cpu_dev, "invalid Vproc value: %d\n", pre_vproc);
28 - return pre_vproc;
29 + ret = pre_vproc;
30 + goto out;
31 }
32
33 freq_hz = freq_table[index].frequency * 1000;
34 @@ -205,7 +206,8 @@ static int mtk_cpufreq_set_target(struct
35 if (IS_ERR(opp)) {
36 dev_err(cpu_dev, "cpu%d: failed to find OPP for %ld\n",
37 policy->cpu, freq_hz);
38 - return PTR_ERR(opp);
39 + ret = PTR_ERR(opp);
40 + goto out;
41 }
42 vproc = dev_pm_opp_get_voltage(opp);
43 dev_pm_opp_put(opp);