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 <quic_smuthana@quicinc.com>
This commit is contained in:
Sandhya Mutha Naga Venkata 2024-04-16 22:16:56 +05:30
commit 044504518a
2 changed files with 14 additions and 1 deletions

View file

@ -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 <linux/init.h>
#include <linux/err.h>
@ -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) {

View file

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