From 241968ed8a33f3bb4d47886e274e8650f2ab989d Mon Sep 17 00:00:00 2001 From: Kogara Naveen Kumar Date: Tue, 26 Apr 2022 18:39:25 +0530 Subject: [PATCH] kernel: Check for buffer overflow and NULL pointer Added check point for buffer overflow and NULL pointer. Change-Id: Ie675de3ad7e30b53424b2333370d9216d4abdfca Signed-off-by: Kogara Naveen Kumar --- asoc/msm-pcm-routing-auto.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/asoc/msm-pcm-routing-auto.c b/asoc/msm-pcm-routing-auto.c index 43eb5344ec3b..3e5f8feabd25 100755 --- a/asoc/msm-pcm-routing-auto.c +++ b/asoc/msm-pcm-routing-auto.c @@ -2224,7 +2224,7 @@ static int msm_pcm_routing_channel_mixer_v2(int fe_id, bool perf_mode, int j = 0, be_id = 0; int ret = 0; - if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) { + if (fe_id >= MSM_FRONTEND_DAI_MAX) { pr_err("%s: invalid FE %d\n", __func__, fe_id); return 0; } @@ -2291,7 +2291,7 @@ static int msm_pcm_routing_channel_mixer(int fe_id, bool perf_mode, return ret; } - if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) { + if (fe_id >= MSM_FRONTEND_DAI_MAX) { pr_err("%s: invalid FE %d\n", __func__, fe_id); return 0; } @@ -32071,6 +32071,10 @@ static int msm_routing_put_device_pp_params_mixer(struct snd_kcontrol *kcontrol, for_each_set_bit(i, &msm_bedais[be_idx].fe_sessions[0], MSM_FRONTEND_DAI_MM_SIZE) { + if (i >= MSM_FRONTEND_DAI_MAX) { + pr_debug("%s: Invalid FE id %d\n", __func__, i); + return -EINVAL; + } if ((fe_dai_map[i][session_type].passthr_mode == LEGACY_PCM) || (fe_dai_map[i][session_type].passthr_mode == LISTEN)) compr_passthr_mode = false; @@ -32777,6 +32781,10 @@ static void get_drift_and_put_asrc(struct work_struct *work) else pr_debug("%s: Succeed to get drift\n", __func__); + if (NULL == &p_asrc_cfg->modules) { + pr_err("%s: Failed to get asrc config modules\n", __func__); + goto exit; + } list_for_each_safe(ptr, next, &p_asrc_cfg->modules) { config_node = list_entry(ptr, struct asrc_module_config_node, list);