All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: lukasz.luba@arm.com
Cc: linux-pm@vger.kernel.org
Subject: [bug report] thermal: devfreq_cooling: refactor code and add get_voltage function
Date: Fri, 31 Mar 2017 18:19:16 +0300	[thread overview]
Message-ID: <20170331151916.GA24860@mwanda> (raw)

Hello Lukasz Luba,

The patch 88db6ba9fd98: "thermal: devfreq_cooling: refactor code and
add get_voltage function" from Mar 14, 2017, leads to the following
static checker warning:

	drivers/thermal/devfreq_cooling.c:187 get_voltage()
	error: 'opp' dereferencing possible ERR_PTR()

drivers/thermal/devfreq_cooling.c
   176  static unsigned long get_voltage(struct devfreq *df, unsigned long freq)
   177  {
   178          struct device *dev = df->dev.parent;
   179          unsigned long voltage;
   180          struct dev_pm_opp *opp;
   181  
   182          opp = dev_pm_opp_find_freq_exact(dev, freq, true);
   183          if (IS_ERR(opp) && (PTR_ERR(opp) == -ERANGE))

Let's imagine that opp is ERR_PTR(-ENOMEM);

   184                  opp = dev_pm_opp_find_freq_exact(dev, freq, false);
   185  
   186          voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */
   187          dev_pm_opp_put(opp);
                               ^^^
Then we would Oops here.

   188  
   189          if (voltage == 0) {
   190                  dev_warn_ratelimited(dev,
   191                                       "Failed to get voltage for frequency %lu: %ld\n",
   192                                       freq, IS_ERR(opp) ? PTR_ERR(opp) : 0);
   193          }
   194  
   195          return voltage;
   196  }

regards,
dan carpenter

             reply	other threads:[~2017-03-31 15:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-31 15:19 Dan Carpenter [this message]
2017-04-03 11:14 ` [bug report] thermal: devfreq_cooling: refactor code and add get_voltage function Lukasz Luba

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=20170331151916.GA24860@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    /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.