Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d365038c authored by Xiaoyu Ye's avatar Xiaoyu Ye Committed by Banajit Goswami
Browse files

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: default avatarXiaoyu Ye <benyxy@codeaurora.org>
parent 3cf42301
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1183,6 +1183,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);
@@ -2750,6 +2751,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);