diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2017-02-06 23:10:03 -0500 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2017-03-12 22:06:42 -0400 |
commit | afd1f4e0a76f0c56422af7056942f28578f1643e (patch) | |
tree | 86382e93001bc19f362e6fb4bf3e4af83c87c1fc /drivers | |
parent | 8327b830f293ff48eaade64b4fc2e247b7655615 (diff) |
thermal: devfreq: Check OPP for errors
It is possible for dev_pm_opp_find_freq_exact() to return errors. It was
all fine earlier as dev_pm_opp_get_voltage() had a check within it to
check for invalid OPPs, but dev_pm_opp_put() doesn't have any similar
checks and the callers need to make sure OPP is valid before calling
them.
Also update the later dev_warn_ratelimited() to not print the error
message as the OPP is guaranteed to be valid now.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/thermal/devfreq_cooling.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c index e99d0e026a53..4bf4ad58cffd 100644 --- a/drivers/thermal/devfreq_cooling.c +++ b/drivers/thermal/devfreq_cooling.c | |||
@@ -189,13 +189,19 @@ get_static_power(struct devfreq_cooling_device *dfc, unsigned long freq) | |||
189 | if (PTR_ERR(opp) == -ERANGE) | 189 | if (PTR_ERR(opp) == -ERANGE) |
190 | opp = dev_pm_opp_find_freq_exact(dev, freq, false); | 190 | opp = dev_pm_opp_find_freq_exact(dev, freq, false); |
191 | 191 | ||
192 | if (IS_ERR(opp)) { | ||
193 | dev_err_ratelimited(dev, "Failed to find OPP for frequency %lu: %ld\n", | ||
194 | freq, PTR_ERR(opp)); | ||
195 | return 0; | ||
196 | } | ||
197 | |||
192 | voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */ | 198 | voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */ |
193 | dev_pm_opp_put(opp); | 199 | dev_pm_opp_put(opp); |
194 | 200 | ||
195 | if (voltage == 0) { | 201 | if (voltage == 0) { |
196 | dev_err_ratelimited(dev, | 202 | dev_err_ratelimited(dev, |
197 | "Failed to get voltage for frequency %lu: %ld\n", | 203 | "Failed to get voltage for frequency %lu\n", |
198 | freq, IS_ERR(opp) ? PTR_ERR(opp) : 0); | 204 | freq); |
199 | return 0; | 205 | return 0; |
200 | } | 206 | } |
201 | 207 | ||