projects
/
linux-block.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
027c700
)
ALSA: echoaudio: Prevent races in calls to set_audio_format()
author
Mark Hills
<mark@xwax.org>
Wed, 8 Jul 2020 10:18:46 +0000
(11:18 +0100)
committer
Takashi Iwai
<tiwai@suse.de>
Thu, 9 Jul 2020 10:58:51 +0000
(12:58 +0200)
The function uses chip->comm_page which needs locking against
other use at the same time.
Signed-off-by: Mark Hills <mark@xwax.org>
Link:
https://lore.kernel.org/r/20200708101848.3457-3-mark@xwax.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/echoaudio/echoaudio.c
patch
|
blob
|
blame
|
history
diff --git
a/sound/pci/echoaudio/echoaudio.c
b/sound/pci/echoaudio/echoaudio.c
index f2bc37c144d60badf6dfcea479a9a580faf143ec..c97928e7e56b5f281961a06ee78f205ba081ebde 100644
(file)
--- a/
sound/pci/echoaudio/echoaudio.c
+++ b/
sound/pci/echoaudio/echoaudio.c
@@
-711,9
+711,22
@@
static int pcm_prepare(struct snd_pcm_substream *substream)
if (snd_BUG_ON(pipe_index >= px_num(chip)))
return -EINVAL;
- if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index)))
+
+ /*
+ * We passed checks we can do independently; now take
+ * exclusive control
+ */
+
+ spin_lock_irq(&chip->lock);
+
+ if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index))) {
+ spin_unlock(&chip->lock);
return -EINVAL;
+ }
+
set_audio_format(chip, pipe_index, &format);
+ spin_unlock_irq(&chip->lock);
+
return 0;
}