[<prev] [next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1110242339500.19795@swampdragon.chaosbits.net>
Date: Mon, 24 Oct 2011 23:41:37 +0200 (CEST)
From: Jesper Juhl <jj@...osbits.net>
To: Greg Kroah-Hartman <gregkh@...e.de>
cc: Markus Grabner <grabner@....tugraz.at>,
Peter Huewe <peterhuewe@....de>, devel@...verdev.osuosl.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] line6: fix memory leaks in line6_init_midi()
If the first call to line6_midibuf_init() fails we'll leak a little
bit of memory. If the second call fails we'll leak a bit more. This
happens when we return from the function and the local variable
'line6midi' goes out of scope.
Signed-off-by: Jesper Juhl <jj@...osbits.net>
---
drivers/staging/line6/midi.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/line6/midi.c b/drivers/staging/line6/midi.c
index e554a2d..86c50cf 100644
--- a/drivers/staging/line6/midi.c
+++ b/drivers/staging/line6/midi.c
@@ -391,12 +391,17 @@ int line6_init_midi(struct usb_line6 *line6)
return -ENOMEM;
err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0);
- if (err < 0)
+ if (err < 0) {
+ kfree(line6midi);
return err;
+ }
err = line6_midibuf_init(&line6midi->midibuf_out, MIDI_BUFFER_SIZE, 1);
- if (err < 0)
+ if (err < 0) {
+ kfree(line6midi->midibuf_in.buf);
+ kfree(line6midi);
return err;
+ }
line6midi->line6 = line6;
line6midi->midi_mask_transmit = 1;
--
1.7.7
--
Jesper Juhl <jj@...osbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists