mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
cpufreq: Remove cpufreq_frequency_get_table()
Most of the callers of cpufreq_frequency_get_table() already have the pointer to a valid 'policy' structure and they don't really need to go through the per-cpu variable first and then a check to validate the frequency, in order to find the freq-table for the policy. Directly use the policy->freq_table field instead for them. Only one user of that API is left after above changes, cpu_cooling.c and it accesses the freq_table in a racy way as the policy can get freed in between. Fix it by using cpufreq_cpu_get() properly. Since there are no more users of cpufreq_frequency_get_table() left, get rid of it. Signed-off-by: Viresh Kumar <[email protected]> Acked-by: Javi Merino <[email protected]> (cpu_cooling.c) Signed-off-by: Rafael J. Wysocki <[email protected]>
This commit is contained in:
parent
f0f879ba53
commit
f8bfc116ca
7 changed files with 39 additions and 42 deletions
|
|
@ -787,22 +787,34 @@ __cpufreq_cooling_register(struct device_node *np,
|
|||
const struct cpumask *clip_cpus, u32 capacitance,
|
||||
get_static_t plat_static_func)
|
||||
{
|
||||
struct cpufreq_policy *policy;
|
||||
struct thermal_cooling_device *cool_dev;
|
||||
struct cpufreq_cooling_device *cpufreq_dev;
|
||||
char dev_name[THERMAL_NAME_LENGTH];
|
||||
struct cpufreq_frequency_table *pos, *table;
|
||||
struct cpumask temp_mask;
|
||||
unsigned int freq, i, num_cpus;
|
||||
int ret;
|
||||
|
||||
table = cpufreq_frequency_get_table(cpumask_first(clip_cpus));
|
||||
if (!table) {
|
||||
pr_debug("%s: CPUFreq table not found\n", __func__);
|
||||
cpumask_and(&temp_mask, clip_cpus, cpu_online_mask);
|
||||
policy = cpufreq_cpu_get(cpumask_first(&temp_mask));
|
||||
if (!policy) {
|
||||
pr_debug("%s: CPUFreq policy not found\n", __func__);
|
||||
return ERR_PTR(-EPROBE_DEFER);
|
||||
}
|
||||
|
||||
table = policy->freq_table;
|
||||
if (!table) {
|
||||
pr_debug("%s: CPUFreq table not found\n", __func__);
|
||||
cool_dev = ERR_PTR(-ENODEV);
|
||||
goto put_policy;
|
||||
}
|
||||
|
||||
cpufreq_dev = kzalloc(sizeof(*cpufreq_dev), GFP_KERNEL);
|
||||
if (!cpufreq_dev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
if (!cpufreq_dev) {
|
||||
cool_dev = ERR_PTR(-ENOMEM);
|
||||
goto put_policy;
|
||||
}
|
||||
|
||||
num_cpus = cpumask_weight(clip_cpus);
|
||||
cpufreq_dev->time_in_idle = kcalloc(num_cpus,
|
||||
|
|
@ -892,7 +904,7 @@ __cpufreq_cooling_register(struct device_node *np,
|
|||
CPUFREQ_POLICY_NOTIFIER);
|
||||
mutex_unlock(&cooling_cpufreq_lock);
|
||||
|
||||
return cool_dev;
|
||||
goto put_policy;
|
||||
|
||||
remove_idr:
|
||||
release_idr(&cpufreq_idr, cpufreq_dev->id);
|
||||
|
|
@ -906,6 +918,8 @@ free_time_in_idle:
|
|||
kfree(cpufreq_dev->time_in_idle);
|
||||
free_cdev:
|
||||
kfree(cpufreq_dev);
|
||||
put_policy:
|
||||
cpufreq_cpu_put(policy);
|
||||
|
||||
return cool_dev;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue