linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: rjw@sisk.pl (Rafael J. Wysocki)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] cpuidle: Prevent null pointer dereference in cpuidle_coupled_cpu_notify
Date: Wed, 15 Aug 2012 22:23:17 +0200	[thread overview]
Message-ID: <201208152223.17623.rjw@sisk.pl> (raw)
In-Reply-To: <1344945151.2674.56.camel@linaro1.home>

On Tuesday, August 14, 2012, Jon Medhurst (Tixy) wrote:
> When a kernel is built to support multiple hardware types it's possible
> that CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is set but the hardware the
> kernel is run on doesn't support cpuidle and therefore doesn't load a
> driver for it. In this case, when the system is shut down,
> cpuidle_coupled_cpu_notify() gets called with cpuidle_devices set to
> NULL. There are quite possibly other circumstances where this
> situation can also occur and we should check for it.
> 
> Signed-off-by: Jon Medhurst <tixy@linaro.org>

Applied to the linux-next branch of the linux-pm.git tree as v3.6 material.

Thanks,
Rafael


> ---
> 
> Would a better fix be to delay registering the notifier until
> cpuidle_coupled_register_device() is called? Though following through
> with that logic would require unregistering the notifier when cpuidle
> driver is unregistered and it still seems possible that there would
> still be a window of opportunity for things to go wrong.
> 
> 
>  drivers/cpuidle/coupled.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpuidle/coupled.c b/drivers/cpuidle/coupled.c
> index 2c9bf26..c78a5ff 100644
> --- a/drivers/cpuidle/coupled.c
> +++ b/drivers/cpuidle/coupled.c
> @@ -681,7 +681,7 @@ static int cpuidle_coupled_cpu_notify(struct notifier_block *nb,
>  	mutex_lock(&cpuidle_lock);
>  
>  	dev = per_cpu(cpuidle_devices, cpu);
> -	if (!dev->coupled)
> +	if (!dev || !dev->coupled)
>  		goto out;
>  
>  	switch (action & ~CPU_TASKS_FROZEN) {
> 

      reply	other threads:[~2012-08-15 20:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14 11:52 [PATCH] cpuidle: Prevent null pointer dereference in cpuidle_coupled_cpu_notify Jon Medhurst (Tixy)
2012-08-15 20:23 ` Rafael J. Wysocki [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201208152223.17623.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).