From b299d420c73bf18692b377881f7c56f4902222d0 Mon Sep 17 00:00:00 2001 From: Park Bumgyu Date: Tue, 1 Aug 2017 19:36:30 +0900 Subject: [PATCH] [COMMON] cpufreq: prevent to access NULL sg_policy Change-Id: If6a532db0dc3a7fe7b3146fd48c03550d5e16fbd Signed-off-by: Park Bumgyu --- kernel/sched/cpufreq_schedutil.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 8f91c8a92011..1a4449f59d4a 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -764,10 +764,10 @@ static void sugov_exit(struct cpufreq_policy *policy) if (!count) sugov_tunables_free(tunables); - mutex_unlock(&global_tunables_lock); - sugov_kthread_stop(sg_policy); sugov_policy_free(sg_policy); + mutex_unlock(&global_tunables_lock); + cpufreq_disable_fast_switch(policy); } @@ -828,6 +828,13 @@ static void sugov_limits(struct cpufreq_policy *policy) { struct sugov_policy *sg_policy = policy->governor_data; + mutex_lock(&global_tunables_lock); + + if (!sg_policy) { + mutex_unlock(&global_tunables_lock); + return; + } + if (!policy->fast_switch_enabled) { mutex_lock(&sg_policy->work_lock); cpufreq_policy_apply_limits(policy); @@ -835,6 +842,8 @@ static void sugov_limits(struct cpufreq_policy *policy) } sg_policy->need_freq_update = true; + + mutex_unlock(&global_tunables_lock); } static struct cpufreq_governor schedutil_gov = { -- 2.20.1