ALSA: sb: Fix potential ABBA deadlock in CSP driver
authorTakashi Iwai <tiwai@suse.de>
Fri, 16 Jul 2021 13:27:23 +0000 (15:27 +0200)
committerTakashi Iwai <tiwai@suse.de>
Sat, 17 Jul 2021 07:55:10 +0000 (09:55 +0200)
commit1c2b9519159b470ef24b2638f4794e86e2952ab7
tree9733fefee4023bb0ed3910d81a0a95635c47399e
parent64752a95b702817602d72f109ceaf5ec0780e283
ALSA: sb: Fix potential ABBA deadlock in CSP driver

SB16 CSP driver may hit potentially a typical ABBA deadlock in two
code paths:

 In snd_sb_csp_stop():
     spin_lock_irqsave(&p->chip->mixer_lock, flags);
     spin_lock(&p->chip->reg_lock);

 In snd_sb_csp_load():
     spin_lock_irqsave(&p->chip->reg_lock, flags);
     spin_lock(&p->chip->mixer_lock);

Also the similar pattern is seen in snd_sb_csp_start().

Although the practical impact is very small (those states aren't
triggered in the same running state and this happens only on a real
hardware, decades old ISA sound boards -- which must be very difficult
to find nowadays), it's a real scenario and has to be fixed.

This patch addresses those deadlocks by splitting the locks in
snd_sb_csp_start() and snd_sb_csp_stop() for avoiding the nested
locks.

Reported-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/7b0fcdaf-cd4f-4728-2eae-48c151a92e10@gmail.com
Link: https://lore.kernel.org/r/20210716132723.13216-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/isa/sb/sb16_csp.c