soc: swr-mstr-ctrl: add check for dev_num and port_id_offset

0 is invalid slave swrm device_num and it should
avoid config swr frameshape.
Add check for port_id_offset to avoid overflow.

Change-Id: I1eae8936c90bb7b66c27f2ff549eef099c25f011
Signed-off-by: Meng Wang <mengw@codeaurora.org>
此提交包含在:
Meng Wang
2021-05-11 11:00:30 +08:00
提交者 Gerrit - the friendly Code Review server
父節點 6b298688f8
當前提交 2042476ef0

查看文件

@@ -1387,6 +1387,8 @@ static void swrm_get_device_frame_shape(struct swr_mstr_ctrl *swrm,
port_id_offset = (port_req->dev_num - 1) *
SWR_MAX_DEV_PORT_NUM +
port_req->slave_port_id;
if (port_id_offset >= SWR_MAX_MSTR_PORT_NUM)
return;
port_req->sinterval =
((swrm->bus_clk * 2) / port_req->ch_rate) - 1;
port_req->offset1 = swrm->pp[uc][port_id_offset].offset1;
@@ -1447,6 +1449,8 @@ static void swrm_copy_data_port_config(struct swr_master *master, u8 bank)
lane_ctrl = 0;
sinterval = 0xFFFF;
list_for_each_entry(port_req, &mport->port_req_list, list) {
if (!port_req->dev_num)
continue;
j++;
slv_id = port_req->slave_port_id;
/* Assumption: If different channels in the same port