From: Andrew Morton on
On Wed, 26 May 2010 22:42:25 -0400 Len Brown <lenb(a)kernel.org> wrote:

> From: Len Brown <len.brown(a)intel.com>
>
> When cpuidle_unregister_driver() is called with a driver
> other than the one that was successfully registered, do nothing.
>
> Previously we'd NULL-out the one that was registered.
> But that required the callers to remember what this
> routine already remembers. With this check, the callers
> can be simplified.
>
> Signed-off-by: Len Brown <len.brown(a)intel.com>
> ---
> drivers/cpuidle/driver.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
> index 2257004..30bcd44 100644
> --- a/drivers/cpuidle/driver.c
> +++ b/drivers/cpuidle/driver.c
> @@ -49,7 +49,8 @@ void cpuidle_unregister_driver(struct cpuidle_driver *drv)
> return;
>
> spin_lock(&cpuidle_driver_lock);
> - cpuidle_curr_driver = NULL;
> + if (drv == cpuidle_curr_driver)
> + cpuidle_curr_driver = NULL;
> spin_unlock(&cpuidle_driver_lock);
> }

This can only happen as a result of a coding bug, yes? If so, the
kernel should go BUG() rather than secretly concealing the problem.

Also (alternatively), the `drv' arg to this function is superfluous?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Andrew Morton on
On Thu, 27 May 2010 01:11:03 -0400 (EDT) Len Brown <lenb(a)kernel.org> wrote:

> From: Len Brown <len.brown(a)intel.com>
>
> BUG_ON() cpuidle_unregister_driver() being called with
> a driver not matching the onee that successfully registered.
>
> Signed-off-by: Len Brown <len.brown(a)intel.com>
> ---
> drivers/cpuidle/driver.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
> index 2257004..5b6fd0f 100644
> --- a/drivers/cpuidle/driver.c
> +++ b/drivers/cpuidle/driver.c
> @@ -45,8 +45,7 @@ EXPORT_SYMBOL_GPL(cpuidle_register_driver);
> */
> void cpuidle_unregister_driver(struct cpuidle_driver *drv)
> {
> - if (!drv)
> - return;
> + BUG_ON(drv != cpuidle_curr_driver)
>
> spin_lock(&cpuidle_driver_lock);
> cpuidle_curr_driver = NULL;

Actually, WARN_ON is nicer ;) There's no point in killing the user's
machine over this recoverable error.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/