[PATCH] Fix maxcpus=1 trigerring BUG() in cpufreq
authorVenki Pallipadi <venkatesh.pallipadi@intel.com>
Mon, 26 Mar 2007 19:03:19 +0000 (12:03 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 27 Mar 2007 15:55:56 +0000 (08:55 -0700)
Ingo reported it on lkml in the thread
  "2.6.21-rc5: maxcpus=1 crash in cpufreq: kernel BUG at drivers/cpufreq/cpufreq.c:82!"

This check added to remove_dev  is symmetric to one in add_dev and handles
callbacks for offline cpus cleanly.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/cpufreq/cpufreq.c

index f52facc570f57c97841b7a4bd809f6929bbe88a8..3162010900c9ebca87408a8d9af763a3852b4c32 100644 (file)
@@ -1015,6 +1015,10 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
 {
        unsigned int cpu = sys_dev->id;
        int retval;
+
+       if (cpu_is_offline(cpu))
+               return 0;
+
        if (unlikely(lock_policy_rwsem_write(cpu)))
                BUG();