ALSA: emux: Fix mutex deadlock at unloading
authorTakashi Iwai <tiwai@suse.de>
Mon, 27 Apr 2015 12:50:39 +0000 (14:50 +0200)
committerSasha Levin <sasha.levin@oracle.com>
Sun, 17 May 2015 23:12:36 +0000 (19:12 -0400)
commit1e568ab9b2d5d97516999e8f3e89fdd330fe2d8c
treeca829e1a72593decf58d69a83ab526205bf6989f
parent3c021baa28e129fec180856a2f5e12c029826e53
ALSA: emux: Fix mutex deadlock at unloading

[ Upstream commit 07b0e5d49d227e3950cb13a3e8caf248ef2a310e ]

The emux-synth driver has a possible AB/BA mutex deadlock at unloading
the emu10k1 driver:

  snd_emux_free() ->
    snd_emux_detach_seq(): mutex_lock(&emu->register_mutex) ->
      snd_seq_delete_kernel_client() ->
        snd_seq_free_client(): mutex_lock(&register_mutex)

  snd_seq_release() ->
    snd_seq_free_client(): mutex_lock(&register_mutex) ->
      snd_seq_delete_all_ports() ->
        snd_emux_unuse(): mutex_lock(&emu->register_mutex)

Basically snd_emux_detach_seq() doesn't need a protection of
emu->register_mutex as it's already being unregistered.  So, we can
get rid of this for avoiding the deadlock.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
sound/synth/emux/emux_seq.c