[alsa-devel] [PATCH 2/2] ALSA: pcm: Use stream lock in snd_pcm_detach_substream()
paulhsia
paulhsia at chromium.org
Tue Nov 12 18:17:15 CET 2019
Since snd_pcm_detach_substream modifies the input substream, the
function should use stream lock to protect the modification section.
Signed-off-by: paulhsia <paulhsia at chromium.org>
---
sound/core/pcm.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 9a72d641743d..06da9cb8984a 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -980,8 +980,12 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime;
- if (PCM_RUNTIME_CHECK(substream))
+ if (snd_BUG_ON(!substream))
return;
+
+ snd_pcm_stream_lock_irq(substream);
+ if (PCM_RUNTIME_CHECK(substream))
+ goto unlock;
runtime = substream->runtime;
if (runtime->private_free != NULL)
runtime->private_free(runtime);
@@ -1000,6 +1004,8 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
put_pid(substream->pid);
substream->pid = NULL;
substream->pstr->substream_opened--;
+ unlock:
+ snd_pcm_stream_unlock_irq(substream);
}
static ssize_t show_pcm_class(struct device *dev,
--
2.24.0.rc1.363.gb1bccd3e3d-goog
More information about the Alsa-devel
mailing list