summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiaoqian Lin <linmq006@gmail.com>2022-05-30 12:54:12 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-22 14:11:23 +0200
commit6506aff2dc2f7059aa3d45ee2e8639b25e87090f (patch)
tree26a612c1f371855388f8aa954d7663dec653b5da
parent940653b51c33210066bf1debdac0d5702a9f7ebc (diff)
downloadlinux-stable-6506aff2dc2f7059aa3d45ee2e8639b25e87090f.tar.gz
linux-stable-6506aff2dc2f7059aa3d45ee2e8639b25e87090f.tar.bz2
linux-stable-6506aff2dc2f7059aa3d45ee2e8639b25e87090f.zip
usb: dwc2: Fix memory leak in dwc2_hcd_init
commit 3755278f078460b021cd0384562977bf2039a57a upstream. usb_create_hcd will alloc memory for hcd, and we should call usb_put_hcd to free it when platform_get_resource() fails to prevent memory leak. goto error2 label instead error1 to fix this. Fixes: 856e6e8e0f93 ("usb: dwc2: check return value after calling platform_get_resource()") Cc: stable <stable@kernel.org> Acked-by: Minas Harutyunyan <hminas@synopsys.com> Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Link: https://lore.kernel.org/r/20220530085413.44068-1-linmq006@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/dwc2/hcd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 78329d0e9af0..a412ef67af18 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -5076,7 +5076,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
retval = -EINVAL;
- goto error1;
+ goto error2;
}
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);