]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: tm6000: fix memory leak
authorKulikov Vasiliy <segooon@gmail.com>
Wed, 11 Aug 2010 08:01:19 +0000 (12:01 +0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 31 Aug 2010 21:51:52 +0000 (14:51 -0700)
Original code doesn't call kfree(chip) on error.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/tm6000/tm6000-alsa.c

index 087137d9164deb1dbf17ba110a0686e7669c6926..6c09ef3c71ea58f4f451bc514907a1c2f8977eb4 100644 (file)
@@ -403,7 +403,7 @@ int tm6000_audio_init(struct tm6000_core *dev)
 
        rc = snd_pcm_new(card, "TM6000 Audio", 0, 0, 1, &pcm);
        if (rc < 0)
-               goto error;
+               goto error_chip;
 
        pcm->info_flags = 0;
        pcm->private_data = chip;
@@ -413,12 +413,15 @@ int tm6000_audio_init(struct tm6000_core *dev)
 
        rc = snd_card_register(card);
        if (rc < 0)
-               goto error;
+               goto error_chip;
 
        dprintk(1,"Registered audio driver for %s\n", card->longname);
 
        return 0;
 
+error_chip:
+       kfree(chip);
+       dev->adev = NULL;
 error:
        snd_card_free(card);
        return rc;