Commit 0c85cefd authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] APM does unsafe conditional set_cpus_allowed

From: Zwane Mwaikambo <zwane@linuxpower.ca>

kapmd does a conditional check in order to decide whether to set the task's
cpu affinity mask.  This can change during runtime, therefore we
unconditionally set it.  There is an early exit in set_cpus_allowed if the
current processor is in the allowed mask anyway.
parent 055e188d
No related merge requests found
......@@ -512,9 +512,8 @@ static unsigned long apm_save_cpus(void)
{
unsigned long x = current->cpus_allowed;
/* Some bioses don't like being called from CPU != 0 */
set_cpus_allowed(current, 1 << 0);
if (unlikely(smp_processor_id() != 0))
BUG();
set_cpus_allowed(current, 1UL << 0);
BUG_ON(smp_processor_id() != 0);
return x;
}
......@@ -914,11 +913,8 @@ static void apm_power_off(void)
*/
#ifdef CONFIG_SMP
/* Some bioses don't like being called from CPU != 0 */
if (smp_processor_id() != 0) {
set_cpus_allowed(current, 1 << 0);
if (unlikely(smp_processor_id() != 0))
BUG();
}
set_cpus_allowed(current, 1UL << 0);
BUG_ON(smp_processor_id() != 0);
#endif
if (apm_info.realmode_power_off)
{
......@@ -1708,11 +1704,8 @@ static int apm(void *unused)
* Some bioses don't like being called from CPU != 0.
* Method suggested by Ingo Molnar.
*/
if (smp_processor_id() != 0) {
set_cpus_allowed(current, 1 << 0);
if (unlikely(smp_processor_id() != 0))
BUG();
}
set_cpus_allowed(current, 1UL << 0);
BUG_ON(smp_processor_id() != 0);
#endif
if (apm_info.connection_version == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment