From: Park Bumgyu Date: Tue, 1 Aug 2017 10:36:30 +0000 (+0900) Subject: [COMMON] cpufreq: prevent to access NULL sg_policy X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b299d420c73bf18692b377881f7c56f4902222d0;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] cpufreq: prevent to access NULL sg_policy Change-Id: If6a532db0dc3a7fe7b3146fd48c03550d5e16fbd Signed-off-by: Park Bumgyu --- 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 = {