This is a note to let you know that I've just added the patch titled

    ALSA: Fix card refcount unbalance

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-fix-card-refcount-unbalance.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 8bb4d9ce08b0a92ca174e41d92c180328f86173f Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Thu, 8 Nov 2012 14:36:18 +0100
Subject: ALSA: Fix card refcount unbalance

From: Takashi Iwai <[email protected]>

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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 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;


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

Reply via email to