Skip to content

Commit

Permalink
usb: dwc2: Fix memory leak in dwc2_hcd_init
Browse files Browse the repository at this point in the history
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: 856e6e8 ("usb: dwc2: check return value after calling platform_get_resource()")
Cc: stable <[email protected]>
Acked-by: Minas Harutyunyan <[email protected]>
Signed-off-by: Miaoqian Lin <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Yuuoniy authored and gregkh committed Jun 10, 2022
1 parent 7ddda26 commit 3755278
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/dwc2/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -5190,7 +5190,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);
Expand Down

0 comments on commit 3755278

Please sign in to comment.