From ad1e75a8ed2b8330151841b8bc322b150a9411c8 Mon Sep 17 00:00:00 2001 From: Shalini Manjunatha Date: Mon, 16 Jun 2025 19:10:01 +0530 Subject: [PATCH] asoc: compress: race condition handling in stream cmd put function protect driver data using mutex lock available to protect against race condtion due to multiple thread access. Change-Id: I7dbff3448958b1700ecca2a090fcb915d5809f30 (cherry picked from commit a9530af1782911e76fa765fd9db7c1ad20710f1d) --- asoc/msm-compress-q6-v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/asoc/msm-compress-q6-v2.c b/asoc/msm-compress-q6-v2.c index 14f549310547..df48c414b05b 100644 --- a/asoc/msm-compress-q6-v2.c +++ b/asoc/msm-compress-q6-v2.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.​ */ @@ -4219,6 +4220,7 @@ static int msm_compr_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol, return -EINVAL; } + mutex_lock(&pdata->lock); cstream = pdata->cstream[fe_id]; if (cstream == NULL) { pr_err("%s cstream is null\n", __func__); @@ -4231,7 +4233,6 @@ static int msm_compr_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol, return -EINVAL; } - mutex_lock(&pdata->lock); if (prtd->audio_client == NULL) { pr_err("%s: audio_client is null\n", __func__); ret = -EINVAL;