diff options
| author | Tapas Kumar Kundu <tkundu@codeaurora.org> | 2015-06-24 07:34:31 -0700 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-23 21:22:32 -0700 |
| commit | 7a391c8e10fe946dc888be4bd26045dc1411387a (patch) | |
| tree | 8204ba4cb68928dea4adfa712c103e51a85976aa | |
| parent | 025f0650f0bddb4d3e3a1ede22e4472c6ecf89ab (diff) | |
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>
| -rw-r--r-- | drivers/soc/qcom/msm_performance.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/soc/qcom/msm_performance.c b/drivers/soc/qcom/msm_performance.c index 079fec1ee239..7e9d9a8013f4 100644 --- a/drivers/soc/qcom/msm_performance.c +++ b/drivers/soc/qcom/msm_performance.c @@ -1718,6 +1718,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; @@ -1732,6 +1734,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); @@ -1741,6 +1745,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; /* @@ -1816,6 +1822,18 @@ static int init_cluster_control(void) GFP_KERNEL); if (!managed_clusters[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; |
