aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2012-10-31 12:44:46 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-14 18:34:22 -0500
commit41682032715c2c969357c81391a442a24dd1c2c2 (patch)
tree8ffc83dc3ba0a4feea15da36c7f2da604be06513 /drivers/cpuidle
parent42f67f2acab2b7179c0d1ab234869e391448dfa6 (diff)
cpuidle: move driver checking within the lock section
The code is racy and the check with cpuidle_curr_driver should be done under the lock. I don't find a path in the different drivers where that could happen because the arch specific drivers are written in such way it is not possible to register a driver while it is unregistered, except maybe in a very improbable case when "intel_idle" and "processor_idle" are competing. One could unregister a driver, while the other one is registering. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Peter De Schrijver <pdeschrijver@nvidia.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/driver.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index 39ba8e181e96..3e5907569233 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -85,17 +85,9 @@ EXPORT_SYMBOL_GPL(cpuidle_get_driver);
85 */ 85 */
86void cpuidle_unregister_driver(struct cpuidle_driver *drv) 86void cpuidle_unregister_driver(struct cpuidle_driver *drv)
87{ 87{
88 if (drv != cpuidle_curr_driver) {
89 WARN(1, "invalid cpuidle_unregister_driver(%s)\n",
90 drv->name);
91 return;
92 }
93
94 spin_lock(&cpuidle_driver_lock); 88 spin_lock(&cpuidle_driver_lock);
95 89 if (drv == cpuidle_curr_driver && !WARN_ON(drv->refcnt > 0))
96 if (!WARN_ON(drv->refcnt > 0))
97 cpuidle_curr_driver = NULL; 90 cpuidle_curr_driver = NULL;
98
99 spin_unlock(&cpuidle_driver_lock); 91 spin_unlock(&cpuidle_driver_lock);
100} 92}
101EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); 93EXPORT_SYMBOL_GPL(cpuidle_unregister_driver);