ARM64: sched: cpufreq_sched: fix bug: init data before use it in thread
authorChen Liang <cl@rock-chips.com>
Thu, 7 Jul 2016 03:41:29 +0000 (11:41 +0800)
committerChen Liang <cl@rock-chips.com>
Thu, 7 Jul 2016 03:56:07 +0000 (11:56 +0800)
policy->governor_data will be use in cpufreq_sched_thread, but it is init
after wake thread, it will cause NULL point access.

Change-Id: I320a3da34560e49f293211be92cb8310d8e395d7
Signed-off-by: Chen Liang <cl@rock-chips.com>
kernel/sched/cpufreq_sched.c

index c608a92..4805339 100644 (file)
@@ -265,6 +265,8 @@ static int cpufreq_sched_policy_init(struct cpufreq_policy *policy)
        pr_debug("%s: throttle threshold = %u [ns]\n",
                  __func__, gd->throttle_nsec);
 
+       policy->governor_data = gd;
+
        if (cpufreq_driver_is_slow()) {
                cpufreq_driver_slow = true;
                gd->task = kthread_create(cpufreq_sched_thread, policy,
@@ -281,7 +283,6 @@ static int cpufreq_sched_policy_init(struct cpufreq_policy *policy)
                init_irq_work(&gd->irq_work, cpufreq_sched_irq_work);
        }
 
-       policy->governor_data = gd;
        set_sched_freq();
 
        return 0;