ASoC: msm: qdsp6v2: Add initialization and range check in q6afe

Add initialization and range check to prevent unattended variables
causing buffer overflow.

CRs-Fixed: 2000634
Change-Id: Ia8a4dfedc7dc4aa300a1012e883c7b23451231f0
Signed-off-by: Xiaoyu Ye <benyxy@codeaurora.org>
This commit is contained in:
Xiaoyu Ye 2017-02-02 12:58:01 -08:00
parent 110e102fe3
commit 9d1c3be760

View file

@ -1178,6 +1178,7 @@ static int afe_send_hw_delay(u16 port_id, u32 rate)
pr_debug("%s:\n", __func__);
memset(&delay_entry, 0, sizeof(delay_entry));
delay_entry.sample_rate = rate;
if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX)
ret = afe_get_cal_hw_delay(TX_DEVICE, &delay_entry);
@ -2680,6 +2681,11 @@ static int q6afe_send_enc_config(u16 port_id,
}
memset(&config, 0, sizeof(config));
index = q6audio_get_port_index(port_id);
if (index < 0) {
pr_err("%s: Invalid index number: %d\n", __func__, index);
return -EINVAL;
}
config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
config.hdr.pkt_size = sizeof(config);