]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpufreq: Explain the kobject_put() in cpufreq_policy_alloc()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 10 May 2019 10:35:53 +0000 (12:35 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 13 May 2019 08:43:53 +0000 (10:43 +0200)
It may not be particularly clear why the kobject_put() after
failing kobject_init_and_add() in cpufreq_policy_alloc() is not
redundant, so add a comment to explain that.

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

index c66eefe928c5888a5582c614effba43cd58f57c3..57a3853a55fb58193ff3a519e754c36ab3511236 100644 (file)
@@ -1134,6 +1134,11 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
                                   cpufreq_global_kobject, "policy%u", cpu);
        if (ret) {
                pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret);
+               /*
+                * The entire policy object will be freed below, but the extra
+                * memory allocated for the kobject name needs to be freed by
+                * releasing the kobject.
+                */
                kobject_put(&policy->kobj);
                goto err_free_real_cpus;
        }