mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-09-22 12:24:38 +00:00
cpufreq: Prevent memory leak in cpufreq_stats on hotplug
Ensures that cpufreq_stats_free_table is called before __cpufreq_remove_dev on cpu hotplug (which also occurs during suspend on SMP systems) to make sure that sysfs_remove_group can get called before the cpufreq kobj is freed. Otherwise, the sysfs file structures are leaked. Change-Id: I87e55277272f5cfad47e9e7c92630e990bb90069 Signed-off-by: Colin Cross <ccross@android.com>
This commit is contained in:
parent
879d744033
commit
32d3498d04
1 changed files with 25 additions and 0 deletions
|
@ -341,6 +341,27 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cpufreq_stats_create_table_cpu(unsigned int cpu)
|
||||
{
|
||||
struct cpufreq_policy *policy;
|
||||
struct cpufreq_frequency_table *table;
|
||||
int ret = -ENODEV;
|
||||
|
||||
policy = cpufreq_cpu_get(cpu);
|
||||
if (!policy)
|
||||
return -ENODEV;
|
||||
|
||||
table = cpufreq_frequency_get_table(cpu);
|
||||
if (!table)
|
||||
goto out;
|
||||
|
||||
ret = cpufreq_stats_create_table(policy, table);
|
||||
|
||||
out:
|
||||
cpufreq_cpu_put(policy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
|
||||
unsigned long action,
|
||||
void *hcpu)
|
||||
|
@ -361,6 +382,10 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
|
|||
cpufreq_stats_free_sysfs(cpu);
|
||||
cpufreq_stats_free_table(cpu);
|
||||
break;
|
||||
case CPU_DOWN_FAILED:
|
||||
case CPU_DOWN_FAILED_FROZEN:
|
||||
cpufreq_stats_create_table_cpu(cpu);
|
||||
break;
|
||||
}
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue