Commit:     41e904dee22066ae7ac3a7f695b2c8bd43ce4e04
Parent:     fa490cfd15d7ce0900097cc4e60cfd7a76381138
Author:     Benjamin Herrenschmidt <[EMAIL PROTECTED]>
AuthorDate: Tue Jun 19 14:37:39 2007 +1000
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Tue Jun 19 14:54:56 2007 +1000

    [POWERPC] Fix snd-powermac refcounting bugs
    The old snd-powermac driver has some serious refcounting issues when
    initialisation fails, which is the case on all new machines with
    a layout-id since those are handled by the new snd-aoa driver.
    Some of those bugs seem to have been under the radar for some time
    (like double pci_dev_put), but one was actually added in 2.6.22 with
    Stephen attempt at teaching refcounting to the driver which didn't
    do it at all.
    This patch fixes both, thus removing all sort of kref errors that
    would happen if that driver gets loaded on a G5 machine or a recent
    PowerBook due to OF nodes left around with a 0 refcount.
    Signed-off-by: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
 sound/ppc/pmac.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 5a2bef4..7a22f0f 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -775,7 +775,8 @@ static int snd_pmac_free(struct snd_pmac *chip)
                out_le32(&chip->awacs->control, in_le32(&chip->awacs->control) 
& 0xfff);
-       snd_pmac_sound_feature(chip, 0);
+       if (chip->node)
+               snd_pmac_sound_feature(chip, 0);
        /* clean up mixer if any */
        if (chip->mixer_free)
@@ -925,6 +926,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
        if (! sound) {
+               chip->node = NULL;
                return -ENODEV;
        prop = of_get_property(sound, "sub-frame", NULL);
@@ -937,7 +939,9 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
                printk(KERN_INFO "snd-powermac no longer handles any "
                                 "machines with a layout-id property "
                                 "in the device-tree, use snd-aoa.\n");
+               of_node_put(sound);
+               chip->node = NULL;
                return -ENODEV;
        /* This should be verified on older screamers */
@@ -1297,8 +1301,6 @@ int __init snd_pmac_new(struct snd_card *card, struct 
snd_pmac **chip_return)
        return 0;
-       if (chip->pdev)
-               pci_dev_put(chip->pdev);
        return err;
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to