linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: "devendra.aaru" <devendra.aaru@gmail.com>
Cc: linux-pm@vger.kernel.org, Durgadoss R <durgadoss.r@intel.com>
Subject: Re: potential NULL dereference at get_target_state in drivers/thermal/fair_share.c
Date: Mon, 01 Apr 2013 09:09:14 +0800	[thread overview]
Message-ID: <1364778554.2178.11.camel@rzhang1-mobl4> (raw)
In-Reply-To: <CAHdPZaOiONMyRdMsYVEQYeMjNsMQb3LG8zfKC0GYJNRtfAVPpA@mail.gmail.com>

On Sat, 2013-03-30 at 15:35 +0530, devendra.aaru wrote:
> Hello Zhang, Durgadoss,
> 
> I have found a code that does this cdev->ops->get_max_state
> 
> static long get_target_state(struct thermal_zone_device *tz,
>                 struct thermal_cooling_device *cdev, int weight, int level)
> {
>         unsigned long max_state;
> 
>         cdev->ops->get_max_state(cdev, &max_state);
> 
>         return (long)(weight * level * max_state) / (100 * tz->trips);
> }
> 
> as the ops can be NULL the panic can occur. if not i have to check for
> a valid get_max_state pointer. so if the ops->get_max_state is NULL
> what should i suppose to be returning here?
> 
any cdev must be registered with valid ops and ops->get_max_state.
if ops or ops->get_max_state is NULL, it suggests a big problem, like
racing issue, etc, and IMO, a panic is more meaningful for us to debug
the problem here.

thanks,
rui


      reply	other threads:[~2013-04-01  1:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-30 10:05 potential NULL dereference at get_target_state in drivers/thermal/fair_share.c devendra.aaru
2013-04-01  1:09 ` Zhang Rui [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=1364778554.2178.11.camel@rzhang1-mobl4 \
    --to=rui.zhang@intel.com \
    --cc=devendra.aaru@gmail.com \
    --cc=durgadoss.r@intel.com \
    --cc=linux-pm@vger.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;
as well as URLs for NNTP newsgroup(s).