cpuidle: add cpuidle_unregister_driver() error check
authorLen Brown <len.brown@intel.com>
Sat, 22 May 2010 20:34:10 +0000 (16:34 -0400)
committerLen Brown <len.brown@intel.com>
Thu, 27 May 2010 17:04:04 +0000 (13:04 -0400)
Assure that cpuidle_unregister_driver() will not clobber
the registered driver if unregistered by somebody else.

Signed-off-by: Len Brown <len.brown@intel.com>
drivers/cpuidle/driver.c

index 2257004fe33d528454a8c40680c08b0ea9335348..826b5c0aa12bb3cd7147ad624ae14861288c620a 100644 (file)
@@ -45,8 +45,11 @@ EXPORT_SYMBOL_GPL(cpuidle_register_driver);
  */
 void cpuidle_unregister_driver(struct cpuidle_driver *drv)
 {
-       if (!drv)
+       if (drv != cpuidle_curr_driver) {
+               WARN(1, "invalid cpuidle_unregister_driver(%s)\n",
+                       drv->name);
                return;
+       }
 
        spin_lock(&cpuidle_driver_lock);
        cpuidle_curr_driver = NULL;