diff --git a/drivers/staging/line6/midi.c b/drivers/staging/line6/midi.c index e554a2da643a6dcc07582a66a8e0de99ccc0a90b..86c50cf9b2a78d1952d36486c7fe33514c227bac 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;