]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] APM does unsafe conditional set_cpus_allowed
authorAndrew Morton <akpm@digeo.com>
Sun, 25 May 2003 08:10:47 +0000 (01:10 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sun, 25 May 2003 08:10:47 +0000 (01:10 -0700)
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.

arch/i386/kernel/apm.c

index 130787b49ef2a62c3f5f94368e5162e79c333906..172f3f9a603d42187d6948592c88428862490759 100644 (file)
@@ -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) {