android_kernel_oneplus_msm8998/sound/pci
Takashi Iwai 097994b3d1 ALSA: hda - Fix deadlock of controller device lock at unbinding
commit ab949d519601880fd46e8bc1445d6a453bf2dc09 upstream.

Imre Deak reported a deadlock of HD-audio driver at unbinding while
it's still in probing.  Since we probe the codecs asynchronously in a
work, the codec driver probe may still be kicked off while the
controller itself is being unbound.  And, azx_remove() tries to
process all pending tasks via cancel_work_sync() for fixing the other
races (see commit [0b8c82190c12: ALSA: hda - Cancel probe work instead
of flush at remove]), now we may meet a bizarre deadlock:

Unbind snd_hda_intel via sysfs:
  device_release_driver() ->
    device_lock(snd_hda_intel) ->
      azx_remove() ->
        cancel_work_sync(azx_probe_work)

azx_probe_work():
  codec driver probe() ->
     __driver_attach() ->
       device_lock(snd_hda_intel)

This deadlock is caused by the fact that both device_release_driver()
and driver_probe_device() take both the device and its parent locks at
the same time.  The codec device sets the controller device as its
parent, and this lock is taken before the probe() callback is called,
while the controller remove() callback gets called also with the same
lock.

In this patch, as an ugly workaround, we unlock the controller device
temporarily during cancel_work_sync() call.  The race against another
bind call should be still suppressed by the parent's device lock.

Reported-by: Imre Deak <imre.deak@intel.com>
Fixes: 0b8c82190c12 ("ALSA: hda - Cancel probe work instead of flush at remove")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-14 13:32:58 +02:00
..
ac97
ali5451 ALSA: ali5451: Fix out-of-bound position reporting 2016-10-16 17:36:14 +02:00
asihpi
au88x0 ALSA: au88x0: Fix calculation in vortex_wtdma_bufshift() 2016-07-27 09:47:38 -07:00
aw2
ca0106
cs46xx ALSA: cs46xx: Fix suspend for all channels 2015-10-30 12:33:21 +01:00
cs5535audio
ctxfi ALSA: ctxfi: Fix the incorrect check of dma_set_mask() call 2017-03-30 09:35:15 +02:00
echoaudio ALSA: echoaudio: Fix memory allocation 2016-07-27 09:47:38 -07:00
emu10k1
hda ALSA: hda - Fix deadlock of controller device lock at unbinding 2017-05-14 13:32:58 +02:00
ice1712
korg1212
lola
lx6464es
mixart
nm256
oxygen
pcxhr ALSA: pcxhr: Fix missing mutex unlock 2016-05-04 14:48:43 -07:00
riptide
rme9652 ALSA: hdspm: Fix zero-division 2016-03-09 15:34:54 -08:00
trident
vx222
ymfpci
ad1889.c
ad1889.h
ak4531_codec.c
als300.c
als4000.c
atiixp.c
atiixp_modem.c
azt3328.c
azt3328.h
bt87x.c
cmipci.c
cs4281.c
cs5530.c
ens1370.c
ens1371.c
es1938.c
es1968.c
fm801.c
intel8x0.c ALSA: intel8x0: Add clock quirk entry for AD1981B on IBM ThinkPad X41. 2016-04-12 09:08:52 -07:00
intel8x0m.c
Kconfig ALSA: Add missing dependency on CONFIG_SND_TIMER 2016-02-17 12:30:58 -08:00
maestro3.c ALSA: maestro3: Fix Allegro mute until master volume/mute is touched 2015-11-02 08:46:30 +01:00
Makefile
rme32.c ALSA: rme32: Use snd_pcm_hw_constraint_single() 2015-10-21 14:24:28 +02:00
rme96.c ALSA: rme96: Fix unexpected volume reset after rate changes 2015-12-04 20:39:49 +01:00
sis7019.c
sis7019.h
sonicvibes.c
via82xx.c
via82xx_modem.c