[PATCH 4.14 38/41] sched/cpufreq/schedutil: Fix error path mutex unlock

From: Greg Kroah-Hartman
Date: Tue Mar 26 2019 - 02:35:33 EST


4.14-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jules Maselbas <jules.maselbas@xxxxxxx>

commit 1b5d43cfb69759d8ef8d30469cea31d0c037aed5 upstream.

This patch prevents the 'global_tunables_lock' mutex from being
unlocked before being locked. This mutex is not locked if the
sugov_kthread_create() function fails.

Signed-off-by: Jules Maselbas <jules.maselbas@xxxxxxx>
Acked-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Chris Redpath <chris.redpath@xxxxxxx>
Cc: Dietmar Eggermann <dietmar.eggemann@xxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Cc: Patrick Bellasi <patrick.bellasi@xxxxxxx>
Cc: Stephen Kyle <stephen.kyle@xxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: nd@xxxxxxx
Link: http://lkml.kernel.org/r/20180329144301.38419-1-jules.maselbas@xxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
kernel/sched/cpufreq_schedutil.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -605,10 +605,9 @@ fail:

stop_kthread:
sugov_kthread_stop(sg_policy);
-
-free_sg_policy:
mutex_unlock(&global_tunables_lock);

+free_sg_policy:
sugov_policy_free(sg_policy);

disable_fast_switch: