[COMMON] cpufreq: prevent to access NULL sg_policy
authorPark Bumgyu <bumgyu.park@samsung.com>
Tue, 1 Aug 2017 10:36:30 +0000 (19:36 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:26:36 +0000 (17:26 +0900)
Change-Id: If6a532db0dc3a7fe7b3146fd48c03550d5e16fbd
Signed-off-by: Park Bumgyu <bumgyu.park@samsung.com>
kernel/sched/cpufreq_schedutil.c

index 8f91c8a92011e1f571b6f5377a92a377ac9642fd..1a4449f59d4a3e32eb77730e7557e7a9c455cb8c 100644 (file)
@@ -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 = {