cpufreq: Avoid double kobject_put() for the same kobject in error code path
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 3 Aug 2013 23:19:41 +0000 (01:19 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 7 Aug 2013 21:02:50 +0000 (23:02 +0200)
The only case triggering a jump to the err_out_unregister label in
__cpufreq_add_dev() is when cpufreq_add_dev_interface() fails.
However, if cpufreq_add_dev_interface() fails, it calls kobject_put()
for the policy kobject in its error code path and since that causes
the kobject's refcount to become 0, the additional kobject_put() for
the same kobject under err_out_unregister and the
wait_for_completion() following it are pointless, so drop them.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/cpufreq.c

index c8b2ca0f44ae111460fdd42bd6a4a9d1f5dbbfd0..924d3f5df26d51bcc835cddc0dc99bb106452014 100644 (file)
@@ -1109,9 +1109,6 @@ err_out_unregister:
        }
        write_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
-       kobject_put(&policy->kobj);
-       wait_for_completion(&policy->kobj_unregister);
-
 err_set_policy_cpu:
        per_cpu(cpufreq_policy_cpu, cpu) = -1;
        cpufreq_policy_free(policy);