mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Naga Chumbalkar <nagananda.chumbalkar@hp.com>
Cc: davej@codemonkey.org.uk, linux-kernel@vger.kernel.org,
	cpufreq@vger.kernel.org, stable@kernel.org
Subject: Re: [PATCH] cpufreq: pcc-cpufreq: sanity check to prevent a NULL pointer dereference
Date: Thu, 8 Sep 2011 16:52:57 -0700	[thread overview]
Message-ID: <20110908165257.7b613baf.akpm@linux-foundation.org> (raw)
In-Reply-To: <20110831200910.27633.20372.sendpatchset@nchumbalkar.americas.cpqcorp.net>

On Wed, 31 Aug 2011 20:08:45 +0000 (UTC)
Naga Chumbalkar <nagananda.chumbalkar@hp.com> wrote:

> If, for whatever reason, "pr" ends up being NULL we would end up in a PANIC 
> as seen below:
> 
> Loading CPUFreq modules[  437.661360] BUG: unable to handle kernel NULL pointer
> dereference at (null)
> IP: [<ffffffffa0434314>] pcc_cpufreq_cpu_init+0x74/0x220 [pcc_cpufreq]
> 
> It's better to prevent the PANIC by failing the driver, and allowing the system to boot.
> 
> Signed-off-by: Naga Chumbalkar <nagananda.chumbalkar@hp.com>
> Cc: stable@kernel.org
> 
> diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
> index 7b0603e..cdc02ac 100644
> --- a/drivers/cpufreq/pcc-cpufreq.c
> +++ b/drivers/cpufreq/pcc-cpufreq.c
> @@ -261,6 +261,9 @@ static int pcc_get_offset(int cpu)
>  	pr = per_cpu(processors, cpu);
>  	pcc_cpu_data = per_cpu_ptr(pcc_cpu_info, cpu);
>  
> +	if (!pr)
> +		return -ENODEV;
> +
>  	status = acpi_evaluate_object(pr->handle, "PCCP", NULL, &buffer);
>  	if (ACPI_FAILURE(status))
>  		return -ENODEV;

hm, from reading drivers/acpi/processor_driver.c it appears that
per_cpu(processors, n)==NULL is an expected and valid state.  Heaven
knows what that state actually *means* - apparently this is a secret.

I assume that you've hit this crash in real live code, hence your
suggestion of a -stable backport?


  reply	other threads:[~2011-09-08 23:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-31 20:08 Naga Chumbalkar
2011-09-08 23:52 ` Andrew Morton [this message]
2011-09-12 17:05   ` Chumbalkar, Nagananda

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=20110908165257.7b613baf.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cpufreq@vger.kernel.org \
    --cc=davej@codemonkey.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nagananda.chumbalkar@hp.com \
    --cc=stable@kernel.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

Powered by JetHome