From 044504518aa566f8b8676aabc93abe89a5a1d388 Mon Sep 17 00:00:00 2001 From: Sandhya Mutha Naga Venkata Date: Tue, 16 Apr 2024 22:16:56 +0530 Subject: [PATCH] Asoc: dsp: Fix to check the list is empty or not Added change to check the list before access it. Change-Id: Ibbf80f157caf06453daefd3a38607b0460157123 Signed-off-by: Sandhya Mutha Naga Venkata --- asoc/msm-lsm-client.c | 9 ++++++++- dsp/q6lsm.c | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/asoc/msm-lsm-client.c b/asoc/msm-lsm-client.c index 443f62e84d01..9b82d8c49a51 100644 --- a/asoc/msm-lsm-client.c +++ b/asoc/msm-lsm-client.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -879,6 +879,13 @@ static int msm_lsm_dereg_model(struct snd_pcm_substream *substream, if (p_info->model_id != 0 && p_info->param_type == LSM_DEREG_MULTI_SND_MODEL) { + + if(list_empty(&client->stage_cfg[p_info->stage_idx].sound_models)) { + pr_err("%s: sound_models list is empty \n", + __func__); + return -EINVAL; + } + list_for_each_entry(sm, &client->stage_cfg[p_info->stage_idx].sound_models, list) { diff --git a/dsp/q6lsm.c b/dsp/q6lsm.c index f79298d0c31d..175c8fcb1a7e 100644 --- a/dsp/q6lsm.c +++ b/dsp/q6lsm.c @@ -2460,6 +2460,12 @@ int q6lsm_set_one_param(struct lsm_client *client, sizeof(struct param_hdr_v2); if (param_type == LSM_REG_MULTI_SND_MODEL) { + if(list_empty(&client->stage_cfg[p_info->stage_idx].sound_models)) { + pr_err("%s: sound_models list is empty \n", + __func__); + return -EINVAL; + } + list_for_each_entry(sm, &client->stage_cfg[p_info->stage_idx].sound_models, list) {