All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Wahren <stefan.wahren@i2se.com>
To: Grigor Tovmasyan <Grigor.Tovmasyan@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>,
	linux-usb@vger.kernel.org, Felipe Balbi <balbi@kernel.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	John Youn <John.Youn@synopsys.com>
Subject: usb: gadget: dwc2: fix memory leak in gadget_init()
Date: Fri, 25 May 2018 08:13:40 +0200 (CEST)	[thread overview]
Message-ID: <881764876.84561.1527228820021@email.1und1.de> (raw)

Hi Grigor,

> Grigor Tovmasyan <Grigor.Tovmasyan@synopsys.com> hat am 24. Mai 2018 um 16:22 geschrieben:
> 
> 
> Freed allocated request for ep0 to prevent memory leak in case when
> dwc2_driver_probe() failed.
> 
> Signed-off-by: Grigor Tovmasyan <tovmasya@synopsys.com>
> Cc: Stefan Wahren <stefan.wahren@i2se.com>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>

currently i don't much time, but at least my tests with Raspberry Pi Zero W were successful.

Tested-by: Stefan Wahren <stefan.wahren@i2se.com>

It would be nice if you can setup some real testing devices at Synopsys in order to identify such regressions faster. kernelci.org only tests the host role of the Raspberry Pi.

Thanks
Stefan

> ---
>  drivers/usb/dwc2/gadget.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index f0d9ccf1d665..7ccf56da1e50 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -4739,9 +4739,11 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
>  	}
>  
>  	ret = usb_add_gadget_udc(dev, &hsotg->gadget);
> -	if (ret)
> +	if (ret) {
> +		dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
> +					   hsotg->ctrl_req);
>  		return ret;
> -
> +	}
>  	dwc2_hsotg_dump(hsotg);
>  
>  	return 0;
> @@ -4755,6 +4757,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
>  int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
>  {
>  	usb_del_gadget_udc(&hsotg->gadget);
> +	dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req);
>  
>  	return 0;
>  }
> -- 
> 2.11.0
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2018-05-25  6:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25  6:13 Stefan Wahren [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-25  9:14 usb: gadget: dwc2: fix memory leak in gadget_init() Minas Harutyunyan
2018-05-25  5:13 Marek Szyprowski
2018-05-24 14:25 Grigor Tovmasyan
2018-05-24 14:22 Grigor Tovmasyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=881764876.84561.1527228820021@email.1und1.de \
    --to=stefan.wahren@i2se.com \
    --cc=Grigor.Tovmasyan@synopsys.com \
    --cc=John.Youn@synopsys.com \
    --cc=Minas.Harutyunyan@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.