summaryrefslogtreecommitdiff
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2011-01-28 19:32:31 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:38:28 -0800
commitae5665eb25692e684769126af44b3d2c8c04cba3 (patch)
treecf85f98f96e74ca4849cf722e58dcc81b16b14eb /drivers/cpufreq
parent820752e31cd510fdcf859a6e269c8b375975317e (diff)
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>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/cpufreq_stats.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index faf7c5217848..c315ec9d5686 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -317,6 +317,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)
@@ -335,6 +356,10 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
case CPU_DEAD_FROZEN:
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;
}