msm: Array bounds check for buffer index

Check the ASM buffer index boundary before using it
to access the buffer to avoid out of array bounds error.

CRs-Fixed: 2145996
Change-Id: I5492941dfd9e7c3fa90af6caec14f9ff7e75d248
Signed-off-by: Vignesh Kulothungan <vigneshk@codeaurora.org>
Esse commit está contido em:
Vignesh Kulothungan
2017-12-04 15:56:05 -08:00
commit de Gerrit - the friendly Code Review server
commit 3817b1847e

Ver arquivo

@@ -184,6 +184,11 @@ static void event_handler(uint32_t opcode,
case ASM_DATA_EVENT_READ_DONE_V2: {
pr_debug("ASM_DATA_EVENT_READ_DONE_V2\n");
buf_index = q6asm_get_buf_index_from_token(token);
if (buf_index >= CAPTURE_MAX_NUM_PERIODS) {
pr_err("%s: buffer index %u is out of range.\n",
__func__, buf_index);
return;
}
pr_debug("%s: token=0x%08x buf_index=0x%08x\n",
__func__, token, buf_index);
prtd->in_frame_info[buf_index].size = payload[4];