All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: lenb@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] intel_idle: Check cpu_idle_get_driver() for NULL before dereferencing it.
Date: Mon, 6 Aug 2012 10:50:10 -0400	[thread overview]
Message-ID: <20120806145009.GD2487@phenom.dumpdata.com> (raw)
In-Reply-To: <201208042356.35884.rjw@sisk.pl>

On Sat, Aug 04, 2012 at 11:56:35PM +0200, Rafael J. Wysocki wrote:
> On Thursday, August 02, 2012, Konrad Rzeszutek Wilk wrote:
> > If the machine is booted without any cpu_idle driver set
> > (b/c disable_cpuidle() has been called) we should follow
> > other users of cpu_idle API and check the return value
> > for NULL before using it.
> > 
> > Reported-by: Mark van Dijk <mark@internecto.net>
> > Tested-by: Mark van Dijk <mark@internecto.net>
> > Suggested-by: Jan Beulich <JBeulich@suse.com>
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > ---
> >  drivers/idle/intel_idle.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
> > index f559088..7383aa0 100644
> > --- a/drivers/idle/intel_idle.c
> > +++ b/drivers/idle/intel_idle.c
> > @@ -607,7 +607,7 @@ static int __init intel_idle_init(void)
> >  	retval = cpuidle_register_driver(&intel_idle_driver);
> >  	if (retval) {
> 
> What about:
> 
>   		struct cpuidle_driver *drv = cpuidle_get_driver();
> 
>   		printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
> 			drv ? drv->name : "none");
> 
> >  		printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
> > -			cpuidle_get_driver()->name);
> > +			cpuidle_get_driver() ? cpuidle_get_driver()->name : "none");
> >  		return retval;
> >  	}
> >  
> > 
> 
> Rafael

Here it is:

>From a8b7aa06cacb5f42a90a0d4a0a1a95e230d43fc6 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Thu, 2 Aug 2012 10:31:52 -0400
Subject: [PATCH] intel_idle: Check cpu_idle_get_driver() for NULL before
 dereferencing it.

If the machine is booted without any cpu_idle driver set
(b/c disable_cpuidle() has been called) we should follow
other users of cpu_idle API and check the return value
for NULL before using it.

Reported-by: Mark van Dijk <mark@internecto.net>
Tested-by: Mark van Dijk <mark@internecto.net>
Suggested-by: Jan Beulich <JBeulich@suse.com>
[v1: Redo per Rafael's suggestion]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 drivers/idle/intel_idle.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index d0f59c3..6b313af 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -556,8 +556,9 @@ static int __init intel_idle_init(void)
 	intel_idle_cpuidle_driver_init();
 	retval = cpuidle_register_driver(&intel_idle_driver);
 	if (retval) {
+		struct cpuidle_driver *drv = cpuidle_get_driver();
 		printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
-			cpuidle_get_driver()->name);
+			drv ? drv->name : "none");
 		return retval;
 	}
 
-- 
1.7.7.6


  parent reply	other threads:[~2012-08-06 15:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02 14:39 [PATCH] intel_idle: Check cpu_idle_get_driver() for NULL before dereferencing it Konrad Rzeszutek Wilk
2012-08-04 21:56 ` Rafael J. Wysocki
2012-08-06 14:33   ` Konrad Rzeszutek Wilk
2012-08-06 14:50   ` Konrad Rzeszutek Wilk [this message]
2012-08-16 20:19     ` Rafael J. Wysocki

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=20120806145009.GD2487@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.