summaryrefslogtreecommitdiff
path: root/drivers/power/qcom
diff options
context:
space:
mode:
authorArchana Sathyakumar <asathyak@codeaurora.org>2016-09-13 14:36:04 -0600
committerArchana Sathyakumar <asathyak@codeaurora.org>2016-09-13 16:03:46 -0600
commit7cb6fcfa75ff503fc335eff51eeb7c9504356b2b (patch)
tree23357b0e6e65f1cbed5866cf9a1d5bc24d98fca8 /drivers/power/qcom
parent9b82a4c5896632b62140d1ddda55638fea254007 (diff)
power: qcom: ea: Fix uninitialized temperature and cpu variable
In trigger_cpu_pwr_stats_calc(), if the local variable 'prev_temp' is already updated with the latest temperature then temp might be used uninitialized. When scheduler's power data snapshot updates in the sampling thread, update the temperature as well if the temperature has been the same for some duration such that temp is used only when the sensor is read. In update_userspace_power, incorrect cpumask could cause the function to use uninitialized cpu variable. Initialize it to -1 at the beginning of the function and treat unmodified value as error condition. Change-Id: Ieccdc3f54f9c9f2cecc6b8578400c6fe44333177 Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Diffstat (limited to 'drivers/power/qcom')
-rw-r--r--drivers/power/qcom/msm-core.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/power/qcom/msm-core.c b/drivers/power/qcom/msm-core.c
index e990425bd63a..727a768e63eb 100644
--- a/drivers/power/qcom/msm-core.c
+++ b/drivers/power/qcom/msm-core.c
@@ -240,10 +240,10 @@ void trigger_cpu_pwr_stats_calc(void)
if (cpu_node->sensor_id < 0)
continue;
- if (cpu_node->temp == prev_temp[cpu])
+ if (cpu_node->temp == prev_temp[cpu]) {
sensor_get_temp(cpu_node->sensor_id, &temp);
-
- cpu_node->temp = temp / scaling_factor;
+ cpu_node->temp = temp / scaling_factor;
+ }
prev_temp[cpu] = cpu_node->temp;
@@ -373,7 +373,7 @@ static int update_userspace_power(struct sched_params __user *argp)
{
int i;
int ret;
- int cpu;
+ int cpu = -1;
struct cpu_activity_info *node;
struct cpu_static_info *sp, *clear_sp;
int cpumask, cluster, mpidr;
@@ -396,7 +396,7 @@ static int update_userspace_power(struct sched_params __user *argp)
}
}
- if (cpu >= num_possible_cpus())
+ if ((cpu < 0) || (cpu >= num_possible_cpus()))
return -EINVAL;
node = &activity[cpu];