提交 41682032 编写于 作者: D Daniel Lezcano 提交者: Rafael J. Wysocki

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: NDaniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: NPeter De Schrijver <pdeschrijver@nvidia.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 42f67f2a
...@@ -85,17 +85,9 @@ EXPORT_SYMBOL_GPL(cpuidle_get_driver); ...@@ -85,17 +85,9 @@ EXPORT_SYMBOL_GPL(cpuidle_get_driver);
*/ */
void cpuidle_unregister_driver(struct cpuidle_driver *drv) void cpuidle_unregister_driver(struct cpuidle_driver *drv)
{ {
if (drv != cpuidle_curr_driver) {
WARN(1, "invalid cpuidle_unregister_driver(%s)\n",
drv->name);
return;
}
spin_lock(&cpuidle_driver_lock); spin_lock(&cpuidle_driver_lock);
if (drv == cpuidle_curr_driver && !WARN_ON(drv->refcnt > 0))
if (!WARN_ON(drv->refcnt > 0))
cpuidle_curr_driver = NULL; cpuidle_curr_driver = NULL;
spin_unlock(&cpuidle_driver_lock); spin_unlock(&cpuidle_driver_lock);
} }
EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); EXPORT_SYMBOL_GPL(cpuidle_unregister_driver);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册