linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] thermal: devfreq_cooling: refactor code and add get_voltage function
@ 2017-03-31 15:19 Dan Carpenter
  2017-04-03 11:14 ` Lukasz Luba
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-03-31 15:19 UTC (permalink / raw)
  To: lukasz.luba; +Cc: linux-pm

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-03 11:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-31 15:19 [bug report] thermal: devfreq_cooling: refactor code and add get_voltage function Dan Carpenter
2017-04-03 11:14 ` Lukasz Luba

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).