This is a note to let you know that I've just added the patch titled
ALSA: usb-audio: Fix mutex deadlock at disconnection
to the 3.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
alsa-usb-audio-fix-mutex-deadlock-at-disconnection.patch
and it can be found in the queue-3.6 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From 10e44239f67d0b6fb74006e61a7e883b8075247a Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Tue, 13 Nov 2012 11:22:48 +0100
Subject: ALSA: usb-audio: Fix mutex deadlock at disconnection
From: Takashi Iwai <[email protected]>
commit 10e44239f67d0b6fb74006e61a7e883b8075247a upstream.
The recent change for USB-audio disconnection race fixes introduced a
mutex deadlock again. There is a circular dependency between
chip->shutdown_rwsem and pcm->open_mutex, depicted like below, when a
device is opened during the disconnection operation:
A. snd_usb_audio_disconnect() ->
card.c::register_mutex ->
chip->shutdown_rwsem (write) ->
snd_card_disconnect() ->
pcm.c::register_mutex ->
pcm->open_mutex
B. snd_pcm_open() ->
pcm->open_mutex ->
snd_usb_pcm_open() ->
chip->shutdown_rwsem (read)
Since the chip->shutdown_rwsem protection in the case A is required
only for turning on the chip->shutdown flag and it doesn't have to be
taken for the whole operation, we can reduce its window in
snd_usb_audio_disconnect().
Reported-by: Jiri Slaby <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
sound/usb/card.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -559,9 +559,11 @@ static void snd_usb_audio_disconnect(str
return;
card = chip->card;
- mutex_lock(®ister_mutex);
down_write(&chip->shutdown_rwsem);
chip->shutdown = 1;
+ up_write(&chip->shutdown_rwsem);
+
+ mutex_lock(®ister_mutex);
chip->num_interfaces--;
if (chip->num_interfaces <= 0) {
snd_card_disconnect(card);
@@ -582,11 +584,9 @@ static void snd_usb_audio_disconnect(str
snd_usb_mixer_disconnect(p);
}
usb_chip[chip->index] = NULL;
- up_write(&chip->shutdown_rwsem);
mutex_unlock(®ister_mutex);
snd_card_free_when_closed(card);
} else {
- up_write(&chip->shutdown_rwsem);
mutex_unlock(®ister_mutex);
}
}
Patches currently in stable-queue which might be from [email protected] are
queue-3.6/alsa-usb-audio-use-rwsem-for-disconnect-protection.patch
queue-3.6/alsa-add-a-reference-counter-to-card-instance.patch
queue-3.6/alsa-fix-card-refcount-unbalance.patch
queue-3.6/alsa-usb-audio-fix-races-at-disconnection-in-mixer_quirks.c.patch
queue-3.6/alsa-usb-audio-fix-races-at-disconnection.patch
queue-3.6/alsa-avoid-endless-sleep-after-disconnect.patch
queue-3.6/alsa-usb-audio-fix-mutex-deadlock-at-disconnection.patch
queue-3.6/alsa-pcm-fix-some-races-at-disconnection.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html