[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <18dfb131-5d9a-2e8b-2f41-c98889d7edae@synopsys.com>
Date: Thu, 2 Jun 2022 11:16:41 +0000
From: Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>
To: Miaoqian Lin <linmq006@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Yang Yingliang <yangyingliang@...wei.com>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] usb: dwc2: Fix memory leak in dwc2_hcd_init
On 5/30/2022 12:54 PM, Miaoqian Lin wrote:
> 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()")
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
Acked-by: Minas Harutyunyan <hminas@...opsys.com>
> ---
> drivers/usb/dwc2/hcd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
> index f63a27d11fac..3f107a06817d 100644
> --- a/drivers/usb/dwc2/hcd.c
> +++ b/drivers/usb/dwc2/hcd.c
> @@ -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);
Powered by blists - more mailing lists