[ALSA] vx - Fix memory leak on error path
authorAlexey Dobriyan <adobriyan@gmail.com>
Mon, 6 Mar 2006 12:21:30 +0000 (13:21 +0100)
committerJaroslav Kysela <perex@suse.cz>
Wed, 22 Mar 2006 09:34:50 +0000 (10:34 +0100)
Modules: Digigram VX core

Noticed by Eric Sesterhenn on kernel-janitors@

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/drivers/vx/vx_pcm.c

index 2195e25087b41fe6546cac7bcdbe2430b8141e35..c4af84995d0544b1173b2152be2c0ab46ab09001 100644 (file)
@@ -1253,9 +1253,13 @@ static int vx_init_audio_io(struct vx_core *chip)
 
        /* allocate pipes */
        chip->playback_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_outs, GFP_KERNEL);
+       if (!chip->playback_pipes)
+               return -ENOMEM;
        chip->capture_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_ins, GFP_KERNEL);
-       if (! chip->playback_pipes || ! chip->capture_pipes)
+       if (!chip->capture_pipes) {
+               kfree(chip->playback_pipes);
                return -ENOMEM;
+       }
 
        memset(chip->playback_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_outs);
        memset(chip->capture_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_ins);