All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: viresh.kumar@linaro.org
Cc: linux-pm@vger.kernel.org
Subject: [bug report] PM / OPP: Update OPP users to put reference
Date: Mon, 6 Feb 2017 11:52:31 +0300	[thread overview]
Message-ID: <20170206083100.GA13489@mwanda> (raw)

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

                 reply	other threads:[~2017-02-06  8:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20170206083100.GA13489@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=viresh.kumar@linaro.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 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.