]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
USB: gadget: midi: memory leak in f_midi_bind_config()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 18 Oct 2011 06:25:34 +0000 (09:25 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 18 Oct 2011 20:51:35 +0000 (13:51 -0700)
There is a small memory leak on the error paths.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/f_midi.c

index ef1bc7a174efaf1b66f4d48720f25be1b02ac5b0..67b222908cf9fe264a3213b945f0beae5fa83569 100644 (file)
@@ -951,7 +951,7 @@ int __init f_midi_bind_config(struct usb_configuration *c,
                struct gmidi_in_port *port = kzalloc(sizeof(*port), GFP_KERNEL);
                if (!port) {
                        status = -ENOMEM;
-                       goto fail;
+                       goto setup_fail;
                }
 
                port->midi = midi;
@@ -989,6 +989,8 @@ int __init f_midi_bind_config(struct usb_configuration *c,
        return 0;
 
 setup_fail:
+       for (--i; i >= 0; i--)
+               kfree(midi->in_port[i]);
        kfree(midi);
 fail:
        return status;