Commit 9d1bec0d authored by Anton Bondarenko's avatar Anton Bondarenko Committed by Kleber Sacilotto de Souza

usb: core: fix potential memory leak in error path during hcd creation

BugLink: http://bugs.launchpad.net/bugs/1702104

commit 1a744d2e upstream.

Free memory allocated for address0_mutex if allocation of bandwidth_mutex
failed.

Fixes: feb26ac3 ("usb: core: hub: hub_port_init lock controller instead of bus")
Signed-off-by: default avatarAnton Bondarenko <anton.bondarenko.sama@gmail.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
parent 5febfd60
...@@ -2540,6 +2540,7 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, ...@@ -2540,6 +2540,7 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex),
GFP_KERNEL); GFP_KERNEL);
if (!hcd->bandwidth_mutex) { if (!hcd->bandwidth_mutex) {
kfree(hcd->address0_mutex);
kfree(hcd); kfree(hcd);
dev_dbg(dev, "hcd bandwidth mutex alloc failed\n"); dev_dbg(dev, "hcd bandwidth mutex alloc failed\n");
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment