Commit 6c331254 authored by Mark Hills's avatar Mark Hills Committed by Takashi Iwai

ALSA: echoaudio: Prevent races in calls to set_audio_format()

The function uses chip->comm_page which needs locking against
other use at the same time.
Signed-off-by: default avatarMark Hills <mark@xwax.org>
Link: https://lore.kernel.org/r/20200708101848.3457-3-mark@xwax.orgSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 027c7002
...@@ -711,9 +711,22 @@ static int pcm_prepare(struct snd_pcm_substream *substream) ...@@ -711,9 +711,22 @@ static int pcm_prepare(struct snd_pcm_substream *substream)
if (snd_BUG_ON(pipe_index >= px_num(chip))) if (snd_BUG_ON(pipe_index >= px_num(chip)))
return -EINVAL; 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; return -EINVAL;
}
set_audio_format(chip, pipe_index, &format); set_audio_format(chip, pipe_index, &format);
spin_unlock_irq(&chip->lock);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment