From: Anton Bondarenko Date: Sat, 6 May 2017 23:53:46 +0000 (+0200) Subject: usb: core: fix potential memory leak in error path during hcd creation X-Git-Tag: v4.14-rc1~869^2~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a744d2eb76aaafb997fda004ae3ae62a1538f85;p=platform%2Fkernel%2Flinux-rpi3.git usb: core: fix potential memory leak in error path during hcd creation 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 Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 5235d6b..5dea983 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -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;