[RFC PATCH v3 08/13] ASoC: soc-compress: protect for_each_dpcm_be() loops
Pierre-Louis Bossart
pierre-louis.bossart at linux.intel.com
Wed Oct 13 16:30:45 CEST 2021
Follow the locking model used within soc-pcm.c
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
---
sound/soc/soc-compress.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 8e2494a9f3a7..a1fc4083c88a 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -158,8 +158,10 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
ret = dpcm_be_dai_startup(fe, stream);
if (ret < 0) {
/* clean up all links */
+ snd_soc_dpcm_fe_lock_irq(fe, stream);
for_each_dpcm_be(fe, stream, dpcm)
dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
+ snd_soc_dpcm_fe_unlock_irq(fe, stream);
dpcm_be_disconnect(fe, stream);
fe->dpcm[stream].runtime = NULL;
@@ -224,8 +226,10 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
dpcm_be_dai_shutdown(fe, stream);
/* mark FE's links ready to prune */
+ snd_soc_dpcm_fe_lock_irq(fe, stream);
for_each_dpcm_be(fe, stream, dpcm)
dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
+ snd_soc_dpcm_fe_unlock_irq(fe, stream);
dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP);
--
2.25.1
More information about the Alsa-devel
mailing list