soc: msm-pcm: Add missing mutex lock to protect prvt data

Add mutex lock to protect private data in _put() and
get() calls.

Change-Id: I776ba5739fec4f1ff6542ef48de79ad3873f1161
Signed-off-by: Soumya Managoli <smanag@codeaurora.org>
This commit is contained in:
Soumya Managoli 2019-11-13 18:53:32 +05:30 committed by syphyr
parent 62d6b9418e
commit 2fe8f6d7b5

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2014, 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, 2019 The Linux Foundation. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -30,6 +30,7 @@
#define LOOPBACK_VOL_MAX_STEPS 0x2000
static DEFINE_MUTEX(loopback_session_lock);
static const DECLARE_TLV_DB_LINEAR(loopback_rx_vol_gain, 0,
LOOPBACK_VOL_MAX_STEPS);
@ -226,6 +227,8 @@ static void stop_pcm(struct msm_pcm_loopback *pcm)
if (pcm->audio_client == NULL)
return;
mutex_lock(&loopback_session_lock);
q6asm_cmd(pcm->audio_client, CMD_CLOSE);
if (pcm->playback_substream != NULL) {
@ -240,6 +243,7 @@ static void stop_pcm(struct msm_pcm_loopback *pcm)
}
q6asm_audio_client_free(pcm->audio_client);
pcm->audio_client = NULL;
mutex_unlock(&loopback_session_lock);
}
static int msm_pcm_close(struct snd_pcm_substream *substream)
@ -364,12 +368,16 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
rc = -ENODEV;
goto exit;
}
mutex_lock(&loopback_session_lock);
prtd = substream->runtime->private_data;
if (!prtd) {
rc = -ENODEV;
mutex_unlock(&loopback_session_lock);
goto exit;
}
rc = pcm_loopback_set_volume(prtd, volume);
mutex_unlock(&loopback_session_lock);
exit:
return rc;
@ -390,12 +398,16 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
rc = -ENODEV;
goto exit;
}
mutex_lock(&loopback_session_lock);
prtd = substream->runtime->private_data;
if (!prtd) {
rc = -ENODEV;
mutex_unlock(&loopback_session_lock);
goto exit;
}
ucontrol->value.integer.value[0] = prtd->volume;
mutex_unlock(&loopback_session_lock);
exit:
return rc;