cpufreq: update user_policy.* on success
authorViresh Kumar <viresh.kumar@linaro.org>
Mon, 3 Aug 2015 03:06:16 +0000 (08:36 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 1 Sep 2015 13:50:39 +0000 (15:50 +0200)
'user_policy' caches properties of a policy that are set by userspace.
And these must be updated only if cpufreq core was successful in
updating them based on request from user space.

In store_scaling_governor(), we are updating user_policy.policy and
user_policy.governor even if cpufreq_set_policy() failed. That's
incorrect.

Fix this by updating user_policy.* only if we were successful in
updating the properties.

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 86d69416821b3791fa52a15b73f390b063c685ce..8e71d8e084397b7792ff3c5f8c7dad071dd055bf 100644 (file)
@@ -671,14 +671,12 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
                return -EINVAL;
 
        ret = cpufreq_set_policy(policy, &new_policy);
+       if (ret)
+               return ret;
 
        policy->user_policy.policy = policy->policy;
        policy->user_policy.governor = policy->governor;
-
-       if (ret)
-               return ret;
-       else
-               return count;
+       return count;
 }
 
 /**