diff options
author | Jesper Juhl <jj@chaosbits.net> | 2011-10-24 23:41:37 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-26 16:14:11 -0800 |
commit | 982d6ab50115025c63f4b9f7175614008c41d449 (patch) | |
tree | fefa5059cef8da3dbb942a69eb217daad5bd322b | |
parent | 6f37aca827e6d075c9e9d3ab1b233cce2a3bc9f1 (diff) | |
download | op-kernel-dev-982d6ab50115025c63f4b9f7175614008c41d449.zip op-kernel-dev-982d6ab50115025c63f4b9f7175614008c41d449.tar.gz |
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@chaosbits.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | 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; |