Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 187da1d9 authored by viresh kumar's avatar viresh kumar Committed by Rafael J. Wysocki
Browse files

cpufreq: stats: do cpufreq_cpu_put() corresponding to cpufreq_cpu_get()



In cpufreq_stats_free_sysfs() we aren't balancing calls to
cpufreq_cpu_get() with cpufreq_cpu_put(). This will never let us have
ref count to policy->kobj as zero.

We will get a hang if somehow cpufreq_driver_unregister() is called.
And that can happen when we compile our driver as module and
insmod/rmmod it.

Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Acked-by: default avatarAmit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 05e99c8c
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -180,14 +180,18 @@ static void cpufreq_stats_free_sysfs(unsigned int cpu)
{
	struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);

	if (!cpufreq_frequency_get_table(cpu))
	if (!policy)
		return;

	if (policy && !policy_is_shared(policy)) {
	if (!cpufreq_frequency_get_table(cpu))
		goto put_ref;

	if (!policy_is_shared(policy)) {
		pr_debug("%s: Free sysfs stat\n", __func__);
		sysfs_remove_group(&policy->kobj, &stats_attr_group);
	}
	if (policy)

put_ref:
	cpufreq_cpu_put(policy);
}