Commit dca947d
committed
ALSA: pcm: Fix races among concurrent read/write and buffer changes
In the current PCM design, the read/write syscalls (as well as the
equivalent ioctls) are allowed before the PCM stream is running, that
is, at PCM PREPARED state. Meanwhile, we also allow to re-issue
hw_params and hw_free ioctl calls at the PREPARED state that may
change or free the buffers, too. The problem is that there is no
protection against those mix-ups.
This patch applies the previously introduced runtime->buffer_mutex to
the read/write operations so that the concurrent hw_params or hw_free
call can no longer interfere during the operation. The mutex is
unlocked before scheduling, so we don't take it too long.
Cc: <stable@vger.kernel.org>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20220322170720.3529-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>1 parent 92ee3c6 commit dca947d
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1906 | 1906 | | |
1907 | 1907 | | |
1908 | 1908 | | |
| 1909 | + | |
1909 | 1910 | | |
1910 | 1911 | | |
1911 | 1912 | | |
| 1913 | + | |
1912 | 1914 | | |
1913 | 1915 | | |
1914 | 1916 | | |
| |||
2219 | 2221 | | |
2220 | 2222 | | |
2221 | 2223 | | |
| 2224 | + | |
2222 | 2225 | | |
2223 | 2226 | | |
2224 | 2227 | | |
| |||
2310 | 2313 | | |
2311 | 2314 | | |
2312 | 2315 | | |
| 2316 | + | |
2313 | 2317 | | |
2314 | 2318 | | |
2315 | 2319 | | |
| |||
0 commit comments