提交 982d6ab5 编写于 作者: J Jesper Juhl 提交者: Greg Kroah-Hartman

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: NJesper Juhl <jj@chaosbits.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 6f37aca8
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册