Skip to contentSkip to conversation

vx: fix memory leak on error path

PATCH New Alexey Dobriyan 1 participant 1 message Mar 4, 2006 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vx: fix memory leak on error path

Noticed by Eric Sesterhenn on kernel-janitors@

---

 sound/drivers/vx/vx_pcm.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
sound/drivers/vx/vx_pcm.c +5 -1
@@ -1254,9 +1254,13 @@ static int vx_init_audio_io(struct vx_co
 
 	/* 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);