]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.6-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Nov 2012 22:58:03 +0000 (14:58 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Nov 2012 22:58:03 +0000 (14:58 -0800)
added patches:
alsa-fix-card-refcount-unbalance.patch
alsa-usb-audio-fix-mutex-deadlock-at-disconnection.patch

queue-3.6/alsa-fix-card-refcount-unbalance.patch [new file with mode: 0644]
queue-3.6/alsa-usb-audio-fix-mutex-deadlock-at-disconnection.patch [new file with mode: 0644]
queue-3.6/series

diff --git a/queue-3.6/alsa-fix-card-refcount-unbalance.patch b/queue-3.6/alsa-fix-card-refcount-unbalance.patch
new file mode 100644 (file)
index 0000000..240d072
--- /dev/null
@@ -0,0 +1,93 @@
+From 8bb4d9ce08b0a92ca174e41d92c180328f86173f Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Thu, 8 Nov 2012 14:36:18 +0100
+Subject: ALSA: Fix card refcount unbalance
+
+From: Takashi Iwai <tiwai@suse.de>
+
+commit 8bb4d9ce08b0a92ca174e41d92c180328f86173f upstream.
+
+There are uncovered cases whether the card refcount introduced by the
+commit a0830dbd isn't properly increased or decreased:
+- OSS PCM and mixer success paths
+- When lookup function gets NULL
+
+This patch fixes these places.
+
+Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=50251
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/core/oss/mixer_oss.c |    1 +
+ sound/core/oss/pcm_oss.c   |    1 +
+ sound/core/pcm_native.c    |    6 ++++--
+ sound/core/sound.c         |    2 +-
+ sound/core/sound_oss.c     |    2 +-
+ 5 files changed, 8 insertions(+), 4 deletions(-)
+
+--- a/sound/core/oss/mixer_oss.c
++++ b/sound/core/oss/mixer_oss.c
+@@ -76,6 +76,7 @@ static int snd_mixer_oss_open(struct ino
+               snd_card_unref(card);
+               return -EFAULT;
+       }
++      snd_card_unref(card);
+       return 0;
+ }
+--- a/sound/core/oss/pcm_oss.c
++++ b/sound/core/oss/pcm_oss.c
+@@ -2454,6 +2454,7 @@ static int snd_pcm_oss_open(struct inode
+       mutex_unlock(&pcm->open_mutex);
+       if (err < 0)
+               goto __error;
++      snd_card_unref(pcm->card);
+       return err;
+       __error:
+--- a/sound/core/pcm_native.c
++++ b/sound/core/pcm_native.c
+@@ -2121,7 +2121,8 @@ static int snd_pcm_playback_open(struct
+       pcm = snd_lookup_minor_data(iminor(inode),
+                                   SNDRV_DEVICE_TYPE_PCM_PLAYBACK);
+       err = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK);
+-      snd_card_unref(pcm->card);
++      if (pcm)
++              snd_card_unref(pcm->card);
+       return err;
+ }
+@@ -2134,7 +2135,8 @@ static int snd_pcm_capture_open(struct i
+       pcm = snd_lookup_minor_data(iminor(inode),
+                                   SNDRV_DEVICE_TYPE_PCM_CAPTURE);
+       err = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE);
+-      snd_card_unref(pcm->card);
++      if (pcm)
++              snd_card_unref(pcm->card);
+       return err;
+ }
+--- a/sound/core/sound.c
++++ b/sound/core/sound.c
+@@ -115,7 +115,7 @@ void *snd_lookup_minor_data(unsigned int
+       mreg = snd_minors[minor];
+       if (mreg && mreg->type == type) {
+               private_data = mreg->private_data;
+-              if (mreg->card_ptr)
++              if (private_data && mreg->card_ptr)
+                       atomic_inc(&mreg->card_ptr->refcount);
+       } else
+               private_data = NULL;
+--- a/sound/core/sound_oss.c
++++ b/sound/core/sound_oss.c
+@@ -54,7 +54,7 @@ void *snd_lookup_oss_minor_data(unsigned
+       mreg = snd_oss_minors[minor];
+       if (mreg && mreg->type == type) {
+               private_data = mreg->private_data;
+-              if (mreg->card_ptr)
++              if (private_data && mreg->card_ptr)
+                       atomic_inc(&mreg->card_ptr->refcount);
+       } else
+               private_data = NULL;
diff --git a/queue-3.6/alsa-usb-audio-fix-mutex-deadlock-at-disconnection.patch b/queue-3.6/alsa-usb-audio-fix-mutex-deadlock-at-disconnection.patch
new file mode 100644 (file)
index 0000000..610e789
--- /dev/null
@@ -0,0 +1,66 @@
+From 10e44239f67d0b6fb74006e61a7e883b8075247a Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Tue, 13 Nov 2012 11:22:48 +0100
+Subject: ALSA: usb-audio: Fix mutex deadlock at disconnection
+
+From: Takashi Iwai <tiwai@suse.de>
+
+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 <jslaby@suse.cz>
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ 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(&register_mutex);
+       down_write(&chip->shutdown_rwsem);
+       chip->shutdown = 1;
++      up_write(&chip->shutdown_rwsem);
++
++      mutex_lock(&register_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(&register_mutex);
+               snd_card_free_when_closed(card);
+       } else {
+-              up_write(&chip->shutdown_rwsem);
+               mutex_unlock(&register_mutex);
+       }
+ }
index 80695d412af83019ea31c2a401179bd7e5964035..22e13fd4a00a81cf87fccb63a908084a9e8ffefe 100644 (file)
@@ -64,3 +64,5 @@ drm-radeon-si-add-some-missing-regs-to-the-vm-reg-checker.patch
 gfs2-test-bufdata-with-buffer-locked-and-gfs2_log_lock-held.patch
 xfs-fix-reading-of-wrapped-log-data.patch
 xfs-fix-buffer-shudown-reference-count-mismatch.patch
+alsa-fix-card-refcount-unbalance.patch
+alsa-usb-audio-fix-mutex-deadlock-at-disconnection.patch