提交 1a744d2e 编写于 作者: A Anton Bondarenko 提交者: Greg Kroah-Hartman

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: feb26ac3 ("usb: core: hub: hub_port_init lock controller instead of bus")
Signed-off-by: NAnton Bondarenko <anton.bondarenko.sama@gmail.com>
Acked-by: NAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 dd5ca753
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册