android_kernel_samsung_msm8976/sound/drivers
Takashi Iwai c793cbfd61 ALSA: aloop: Fix racy hw constraints adjustment
commit 898dfe4687f460ba337a01c11549f87269a13fa2 upstream.

The aloop driver tries to update the hw constraints of the connected
target on the cable of the opened PCM substream.  This is done by
adding the extra hw constraints rules referring to the substream
runtime->hw fields, while the other substream may update the runtime
hw of another side on the fly.

This is, however, racy and may result in the inconsistent values when
both PCM streams perform the prepare concurrently.  One of the reason
is that it overwrites the other's runtime->hw field; which is not only
racy but also broken when it's called before the open of another side
finishes.  And, since the reference to runtime->hw isn't protected,
the concurrent write may give the partial value update and become
inconsistent.

This patch is an attempt to fix and clean up:
- The prepare doesn't change the runtime->hw of other side any longer,
  but only update the cable->hw that is referred commonly.
- The extra rules refer to the loopback_pcm object instead of the
  runtime->hw.  The actual hw is deduced from cable->hw.
- The extra rules take the cable_lock to protect against the race.

Fixes: b1c73fc8e6 ("ALSA: snd-aloop: Fix hw_params restrictions and checking")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-07-27 21:46:27 +02:00
..
mpu401 ALSA: add/change some comments describing function return values 2013-03-12 08:32:53 +01:00
opl3 sound: Remove unnecessary semicolon 2012-10-06 16:47:53 +02:00
opl4 ALSA: opl4: use list_move_tail instead of list_del/list_add_tail 2012-09-05 09:14:45 +02:00
pcsp ALSA: drivers: remove __dev* attributes 2012-12-07 07:34:32 +01:00
vx ALSA: Make snd_printd() and snd_printdd() inline 2013-01-25 18:32:14 +01:00
Kconfig ALSA: sound kconfig typo 2013-04-24 14:02:36 +02:00
Makefile
aloop.c ALSA: aloop: Fix racy hw constraints adjustment 2019-07-27 21:46:27 +02:00
dummy.c ALSA: dummy: Fix a use-after-free at closing 2019-07-27 21:41:56 +02:00
ml403-ac97cr.c ALSA: drivers: remove __dev* attributes 2012-12-07 07:34:32 +01:00
mtpav.c ALSA: drivers: remove __dev* attributes 2012-12-07 07:34:32 +01:00
mts64.c ALSA: drivers: remove __dev* attributes 2012-12-07 07:34:32 +01:00
pcm-indirect2.c Fix common misspellings 2011-03-31 11:26:23 -03:00
pcm-indirect2.h
portman2x4.c ALSA: drivers: remove __dev* attributes 2012-12-07 07:34:32 +01:00
serial-u16550.c ALSA: drivers: remove __dev* attributes 2012-12-07 07:34:32 +01:00
virmidi.c ALSA: drivers: remove __dev* attributes 2012-12-07 07:34:32 +01:00