diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index 77472d1df7..7164e9687a 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -2792,6 +2792,13 @@ static int swrm_probe(struct platform_device *pdev) if (port_num != old_port_num) ch_iter = 0; + if (port_num > SWR_MSTR_PORT_LEN || + ch_iter >= SWR_MAX_CH_PER_PORT) { + dev_err(&pdev->dev, + "%s:invalid port_num %d or ch_iter %d\n", + __func__, port_num, ch_iter); + goto err_pdata_fail; + } swrm->port_mapping[port_num][ch_iter].port_type = port_type; swrm->port_mapping[port_num][ch_iter++].ch_mask = ch_mask; old_port_num = port_num; diff --git a/soc/swr-mstr-ctrl.h b/soc/swr-mstr-ctrl.h index 196039a07a..4b9f6057dd 100644 --- a/soc/swr-mstr-ctrl.h +++ b/soc/swr-mstr-ctrl.h @@ -171,7 +171,7 @@ struct swr_mstr_ctrl { struct work_struct dc_presence_work; u8 num_ports; struct swrm_port_type - port_mapping[SWR_MSTR_PORT_LEN][SWR_MAX_CH_PER_PORT]; + port_mapping[SWR_MSTR_PORT_LEN + 1][SWR_MAX_CH_PER_PORT]; int swr_irq; u32 clk_stop_mode0_supp; struct work_struct wakeup_work;