]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: core: fix potential memory leak in error path during hcd creation
authorAnton Bondarenko <anton.bondarenko.sama@gmail.com>
Sat, 6 May 2017 23:53:46 +0000 (01:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2017 09:27:41 +0000 (11:27 +0200)
Free memory allocated for address0_mutex if allocation of bandwidth_mutex
failed.

Fixes: feb26ac31a2a ("usb: core: hub: hub_port_init lock controller instead of bus")
Signed-off-by: Anton Bondarenko <anton.bondarenko.sama@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hcd.c

index 5235d6be1bdff7e2eebe9e9af1b116d38033e226..5dea98358c05c46b09f913fee8b7c48d9f2c4f85 100644 (file)
@@ -2520,6 +2520,7 @@ struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
                hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex),
                                GFP_KERNEL);
                if (!hcd->bandwidth_mutex) {
+                       kfree(hcd->address0_mutex);
                        kfree(hcd);
                        dev_dbg(dev, "hcd bandwidth mutex alloc failed\n");
                        return NULL;