linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] PM / OPP: Update OPP users to put reference
@ 2017-02-06  8:52 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2017-02-06  8:52 UTC (permalink / raw)
  To: viresh.kumar; +Cc: linux-pm

Hello Viresh Kumar,

The patch 8a31d9d94297: "PM / OPP: Update OPP users to put reference"
from Jan 23, 2017, leads to the following static checker warning:

	drivers/thermal/devfreq_cooling.c:193 get_static_power()
	error: 'opp' dereferencing possible ERR_PTR()

drivers/thermal/devfreq_cooling.c
   177  static unsigned long
   178  get_static_power(struct devfreq_cooling_device *dfc, unsigned long freq)
   179  {
   180          struct devfreq *df = dfc->devfreq;
   181          struct device *dev = df->dev.parent;
   182          unsigned long voltage;
   183          struct dev_pm_opp *opp;
   184  
   185          if (!dfc->power_ops->get_static_power)
   186                  return 0;
   187  
   188          opp = dev_pm_opp_find_freq_exact(dev, freq, true);
   189          if (IS_ERR(opp) && (PTR_ERR(opp) == -ERANGE))

You could just write:

		if (PTR_ERR(opp) == -ERANGE))

Or was || intended instead of &&?

   190                  opp = dev_pm_opp_find_freq_exact(dev, freq, false);
   191  
   192          voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */
   193          dev_pm_opp_put(opp);

Anyway, we added a new dereference here, inside the function.

   194  
   195          if (voltage == 0) {
   196                  dev_warn_ratelimited(dev,
   197                                       "Failed to get voltage for frequency %lu: %ld\n",
   198                                       freq, IS_ERR(opp) ? PTR_ERR(opp) : 0);
   199                  return 0;
   200          }
   201  
   202          return dfc->power_ops->get_static_power(df, voltage);
   203  }

The same thing for get_static_power() in drivers/thermal/cpu_cooling.c.

    drivers/thermal/cpu_cooling.c:399 get_static_power()
    error: 'opp' dereferencing possible ERR_PTR()


regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-06  8:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-06  8:52 [bug report] PM / OPP: Update OPP users to put reference Dan Carpenter

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