mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-25 14:13:01 -04:00
drivers: thermal: Update a variable type in QMI encode logic
Change a variable type in QMI encode logic to avoid buffer overflow scenario. Change-Id: I11b10cce0e9ab5b02738b2ba13e637df979e9310 Signed-off-by: Gopala Krishna Nuthaki <gnuthaki@codeaurora.org>
This commit is contained in:
parent
756bbb2594
commit
d4f65badf3
1 changed files with 9 additions and 3 deletions
|
|
@ -188,7 +188,7 @@ static char sensor_clients[QMI_TS_MAX_NR][QMI_CLIENT_NAME_LENGTH] = {
|
|||
static int32_t encode_qmi(int32_t val)
|
||||
{
|
||||
uint32_t shift = 0, local_val = 0;
|
||||
int32_t temp_val = 0;
|
||||
unsigned long temp_val = 0;
|
||||
|
||||
if (val == INT_MAX || val == INT_MIN)
|
||||
return 0;
|
||||
|
|
@ -198,8 +198,7 @@ static int32_t encode_qmi(int32_t val)
|
|||
temp_val *= -1;
|
||||
local_val |= 1 << QMI_FL_SIGN_BIT;
|
||||
}
|
||||
shift = find_last_bit((const unsigned long *)&temp_val,
|
||||
sizeof(temp_val) * 8);
|
||||
shift = find_last_bit(&temp_val, sizeof(temp_val) * 8);
|
||||
local_val |= ((shift + 127) << QMI_MANTISSA_MSB);
|
||||
temp_val &= ~(1 << shift);
|
||||
|
||||
|
|
@ -344,6 +343,13 @@ static int qmi_ts_request(struct qmi_sensor *qmi_sens,
|
|||
qmi_sens->low_thresh != INT_MIN;
|
||||
req.temp_threshold_low =
|
||||
encode_qmi(qmi_sens->low_thresh);
|
||||
|
||||
pr_debug("Sensor:%s set high_trip:%d, low_trip:%d, high_valid:%d, low_valid:%d\n",
|
||||
qmi_sens->qmi_name,
|
||||
qmi_sens->high_thresh,
|
||||
qmi_sens->low_thresh,
|
||||
req.temp_threshold_high_valid,
|
||||
req.temp_threshold_low_valid);
|
||||
}
|
||||
|
||||
mutex_lock(&ts->mutex);
|
||||
|
|
|
|||
Loading…
Reference in a new issue