[CPUFREQ] core: CPUFREQ_GOV_STOP needs to be last Assert that the call to the cpufreq governor with CPUFREQ_GOV_STOP is really the last. Without this patch, some strange in-kernel preemption combined with the scheduler disliking the "removing" task may cause the opposite. Signed-off-by: Dominik Brodowski diff -ruN linux-original/drivers/cpufreq/cpufreq.c linux/drivers/cpufreq/cpufreq.c --- linux-original/drivers/cpufreq/cpufreq.c 2004-11-01 23:24:45.000000000 +0100 +++ linux/drivers/cpufreq/cpufreq.c 2004-11-02 22:51:22.000000000 +0100 @@ -763,8 +763,11 @@ spin_unlock_irqrestore(&cpufreq_driver_lock, flags); #endif + down(&data->lock); if (cpufreq_driver->target) __cpufreq_governor(data, CPUFREQ_GOV_STOP); + cpufreq_driver->target = NULL; + up(&data->lock); kobject_unregister(&data->kobj); @@ -1025,7 +1029,7 @@ lock_cpu_hotplug(); dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu, target_freq, relation); - if (cpu_online(policy->cpu)) + if (cpu_online(policy->cpu) && cpufreq_driver->target) retval = cpufreq_driver->target(policy, target_freq, relation); unlock_cpu_hotplug(); return retval;