cpufreq: Return error if ->get() failed in cpufreq_update_policy()
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 25 Feb 2014 08:59:44 +0000 (14:29 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 1 Mar 2014 00:39:30 +0000 (01:39 +0100)
cpufreq_update_policy() calls cpufreq_driver->get() to get current
frequency of a CPU and it is not supposed to fail or return zero.
Return error in case that happens.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c

index 5815af50d3de175517ffb658d860ef8946aebdbd..56b7b1be352ddc2bb4ec1e2cec67b781c4a05490 100644 (file)
@@ -2139,6 +2139,11 @@ int cpufreq_update_policy(unsigned int cpu)
         */
        if (cpufreq_driver->get) {
                new_policy.cur = cpufreq_driver->get(cpu);
+               if (WARN_ON(!new_policy.cur)) {
+                       ret = -EIO;
+                       goto no_policy;
+               }
+
                if (!policy->cur) {
                        pr_debug("Driver did not initialize current freq");
                        policy->cur = new_policy.cur;