cpufreq: Fix cpufreq_online() return value on errors
authorWang ShaoBo <bobo.shaobowang@huawei.com>
Thu, 26 Nov 2020 01:12:39 +0000 (09:12 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 11 Dec 2020 18:54:17 +0000 (19:54 +0100)
Make cpufreq_online() return negative error codes on all errors that
cause the policy to be destroyed, as appropriate.

Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c

index 95d2555..c17aa29 100644 (file)
@@ -1393,8 +1393,10 @@ static int cpufreq_online(unsigned int cpu)
 
                policy->min_freq_req = kzalloc(2 * sizeof(*policy->min_freq_req),
                                               GFP_KERNEL);
-               if (!policy->min_freq_req)
+               if (!policy->min_freq_req) {
+                       ret = -ENOMEM;
                        goto out_destroy_policy;
+               }
 
                ret = freq_qos_add_request(&policy->constraints,
                                           policy->min_freq_req, FREQ_QOS_MIN,
@@ -1431,6 +1433,7 @@ static int cpufreq_online(unsigned int cpu)
        if (cpufreq_driver->get && has_target()) {
                policy->cur = cpufreq_driver->get(policy->cpu);
                if (!policy->cur) {
+                       ret = -EIO;
                        pr_err("%s: ->get() failed\n", __func__);
                        goto out_destroy_policy;
                }