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>
This commit is contained in:
parent
9b82a4c589
commit
7cb6fcfa75
1 changed files with 5 additions and 5 deletions
|
@ -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];
|
||||
|
|
Loading…
Add table
Reference in a new issue