soc: qcom: msm_perf: prevent cpumask bits to be NULL

This changes fixes NULL pointer derefence issue for
cpumask variabls for clusters.

Change-Id: Ifa73a43213b6afdfde57285393f9729a954acfc3
Signed-off-by: Tapas Kumar Kundu <tkundu@codeaurora.org>
This commit is contained in:
Tapas Kumar Kundu 2015-06-01 15:40:59 -07:00 committed by Gerrit - the friendly Code Review server
parent c9f90310a6
commit c262958610
1 changed files with 18 additions and 1 deletions

View File

@ -1639,6 +1639,8 @@ static int __ref msm_performance_cpu_callback(struct notifier_block *nfb,
return NOTIFY_OK;
for (i = 0; i < num_clusters; i++) {
if (managed_clusters[i]->cpus == NULL)
return NOTIFY_OK;
if (cpumask_test_cpu(cpu, managed_clusters[i]->cpus)) {
i_cl = managed_clusters[i];
break;
@ -1653,6 +1655,8 @@ static int __ref msm_performance_cpu_callback(struct notifier_block *nfb,
* Prevent onlining of a managed CPU if max_cpu criteria is
* already satisfied
*/
if (i_cl->offlined_cpus == NULL)
return NOTIFY_OK;
if (i_cl->max_cpu_request <=
num_online_managed(i_cl->cpus)) {
pr_debug("msm_perf: Prevent CPU%d onlining\n", cpu);
@ -1662,6 +1666,8 @@ static int __ref msm_performance_cpu_callback(struct notifier_block *nfb,
cpumask_clear_cpu(cpu, i_cl->offlined_cpus);
} else if (action == CPU_DEAD) {
if (i_cl->offlined_cpus == NULL)
return NOTIFY_OK;
if (cpumask_test_cpu(cpu, i_cl->offlined_cpus))
return NOTIFY_OK;
/*
@ -1741,7 +1747,18 @@ static int init_cluster_control(void)
pr_err("msm_perf:Cluster %u mem alloc failed\n", i);
return -ENOMEM;
}
if (!alloc_cpumask_var(&managed_clusters[i]->cpus,
GFP_KERNEL)) {
pr_err("msm_perf:Cluster %u cpu alloc failed\n",
i);
return -ENOMEM;
}
if (!alloc_cpumask_var(&managed_clusters[i]->offlined_cpus,
GFP_KERNEL)) {
pr_err("msm_perf:Cluster %u off_cpus alloc failed\n",
i);
return -ENOMEM;
}
managed_clusters[i]->max_cpu_request = -1;
managed_clusters[i]->single_enter_load = DEF_SINGLE_ENT;
managed_clusters[i]->single_exit_load = DEF_SINGLE_EX;