[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191112171715.128727-3-paulhsia@chromium.org>
Date: Wed, 13 Nov 2019 01:17:15 +0800
From: paulhsia <paulhsia@...omium.org>
To: linux-kernel@...r.kernel.org
Cc: Mark Brown <broonie@...nel.org>, Takashi Iwai <tiwai@...e.com>,
alsa-devel@...a-project.org, paulhsia <paulhsia@...omium.org>
Subject: [PATCH 2/2] ALSA: pcm: Use stream lock in snd_pcm_detach_substream()
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@...omium.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
Powered by blists - more mailing lists