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 <quic_nkogara@quicinc.com>
This commit is contained in:
Kogara Naveen Kumar 2022-04-26 18:39:25 +05:30 • committed by Gerrit - the friendly Code Review server
commit 241968ed8a

View file

@ -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);