diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index beea152292da..4ec798709d3b 100644 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -1866,6 +1866,11 @@ static int msm_pcm_routing_channel_mixer_v2(int fe_id, bool perf_mode, } be_id = channel_mixer_v2[fe_id][sess_type].port_idx - 1; + if (be_id < 0 || be_id >= MSM_BACKEND_DAI_MAX) { + pr_err("%s: Received out of bounds be_id %d\n", + __func__, be_id); + return -EINVAL; + } channel_mixer_v2[fe_id][sess_type].input_channels[0] = channel_mixer_v2[fe_id][sess_type].input_channel; @@ -31793,9 +31798,9 @@ static int asrc_get_module_location(struct asrc_module_config_params *params, int *copp_index, int *port_id) { int ret = 0; - int fe_id = params->fe_id; - int dir = params->dir; - int be_id = params->be_id; + int fe_id = 0; + int dir = 0; + int be_id = 0; int copp_idx = 0; unsigned long copp = -1; bool copp_is_found = false; @@ -31811,6 +31816,9 @@ static int asrc_get_module_location(struct asrc_module_config_params *params, goto done; } + fe_id = params->fe_id; + dir = params->dir; + be_id = params->be_id; bedai = &msm_bedais[be_id]; if (afe_get_port_type(bedai->port_id) != port_type) { pr_err("%s: port_type not match: be_dai %d type %d\n", @@ -31977,7 +31985,7 @@ static void get_drift_and_put_asrc(struct work_struct *work) struct asrc_config *p_asrc_cfg = NULL; struct afe_param_id_dev_timing_stats timing_stats = {0}; struct asrc_module_config_node *config_node = NULL; - struct list_head *ptr, *next; + struct list_head *ptr = NULL, *next = NULL; delayed_drift_work = to_delayed_work(work); if (NULL == delayed_drift_work) { @@ -32154,6 +32162,11 @@ static int msm_dai_q6_asrc_config_put( break; case ENABLE_ASRC_DRIFT_HW: idx = get_drift_src_idx(param & ~0x0100); /* group device */ + if (idx < 0 || idx >= DRIFT_SRC_MAX) { + pr_err("%s Invalid index: %d\n", __func__, idx); + ret = -EINVAL; + goto done; + } mutex_lock(&asrc_cfg[idx].lock); asrc_cfg[idx].drift_src = param & ~0x0100; mutex_unlock(&asrc_cfg[idx].lock);