public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] usb: gadget: f_thor: free the allocated out request buffer
@ 2015-12-07 11:59 Michal Simek
  2016-02-04 11:34 ` Michal Simek
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2015-12-07 11:59 UTC (permalink / raw)
  To: u-boot

From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>

Fix the memory leak by freeing the allocated out request buffer

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/usb/gadget/f_thor.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index a60e9487e774..75b72902c9d5 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -51,6 +51,7 @@ DEFINE_CACHE_ALIGN_BUFFER(unsigned char, thor_rx_data_buf,
 DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE);
 static unsigned long long int thor_file_size;
 static int alt_setting_num;
+static void *out_req_buf;
 
 static void send_rsp(const struct rsp_box *rsp)
 {
@@ -891,6 +892,8 @@ static void thor_func_disable(struct usb_function *f)
 	}
 
 	if (dev->out_ep->driver_data) {
+		if (out_req_buf)
+			free(out_req_buf);
 		dev->out_req->buf = NULL;
 		usb_ep_free_request(dev->out_ep, dev->out_req);
 		usb_ep_disable(dev->out_ep);
@@ -947,6 +950,7 @@ static int thor_eps_setup(struct usb_function *f)
 	}
 
 	dev->out_req = req;
+	out_req_buf = dev->out_req->buf;
 	/* ACM control EP */
 	ep = dev->int_ep;
 	ep->driver_data = cdev;	/* claim */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] usb: gadget: f_thor: free the allocated out request buffer
  2015-12-07 11:59 [U-Boot] [PATCH] usb: gadget: f_thor: free the allocated out request buffer Michal Simek
@ 2016-02-04 11:34 ` Michal Simek
  2016-02-04 11:41   ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2016-02-04 11:34 UTC (permalink / raw)
  To: u-boot

Hi guys,

On 7.12.2015 12:59, Michal Simek wrote:
> From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
> 
> Fix the memory leak by freeing the allocated out request buffer
> 
> Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>  drivers/usb/gadget/f_thor.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
> index a60e9487e774..75b72902c9d5 100644
> --- a/drivers/usb/gadget/f_thor.c
> +++ b/drivers/usb/gadget/f_thor.c
> @@ -51,6 +51,7 @@ DEFINE_CACHE_ALIGN_BUFFER(unsigned char, thor_rx_data_buf,
>  DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE);
>  static unsigned long long int thor_file_size;
>  static int alt_setting_num;
> +static void *out_req_buf;
>  
>  static void send_rsp(const struct rsp_box *rsp)
>  {
> @@ -891,6 +892,8 @@ static void thor_func_disable(struct usb_function *f)
>  	}
>  
>  	if (dev->out_ep->driver_data) {
> +		if (out_req_buf)
> +			free(out_req_buf);
>  		dev->out_req->buf = NULL;
>  		usb_ep_free_request(dev->out_ep, dev->out_req);
>  		usb_ep_disable(dev->out_ep);
> @@ -947,6 +950,7 @@ static int thor_eps_setup(struct usb_function *f)
>  	}
>  
>  	dev->out_req = req;
> +	out_req_buf = dev->out_req->buf;
>  	/* ACM control EP */
>  	ep = dev->int_ep;
>  	ep->driver_data = cdev;	/* claim */
> 

any update on this one?

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160204/836c7cb3/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] usb: gadget: f_thor: free the allocated out request buffer
  2016-02-04 11:34 ` Michal Simek
@ 2016-02-04 11:41   ` Marek Vasut
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2016-02-04 11:41 UTC (permalink / raw)
  To: u-boot

On Thursday, February 04, 2016 at 12:34:57 PM, Michal Simek wrote:
> Hi guys,
> 
> On 7.12.2015 12:59, Michal Simek wrote:
> > From: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
> > 
> > Fix the memory leak by freeing the allocated out request buffer
> > 
> > Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> > Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> > ---
> > 
> >  drivers/usb/gadget/f_thor.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
> > index a60e9487e774..75b72902c9d5 100644
> > --- a/drivers/usb/gadget/f_thor.c
> > +++ b/drivers/usb/gadget/f_thor.c
> > @@ -51,6 +51,7 @@ DEFINE_CACHE_ALIGN_BUFFER(unsigned char,
> > thor_rx_data_buf,
> > 
> >  DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE);
> >  static unsigned long long int thor_file_size;
> >  static int alt_setting_num;
> > 
> > +static void *out_req_buf;
> > 
> >  static void send_rsp(const struct rsp_box *rsp)
> >  {
> > 
> > @@ -891,6 +892,8 @@ static void thor_func_disable(struct usb_function *f)
> > 
> >  	}
> >  	
> >  	if (dev->out_ep->driver_data) {
> > 
> > +		if (out_req_buf)
> > +			free(out_req_buf);

Why don't you call free(dev->out_req->buf); here instead ? Then you won't need
that new variable you introduce.

> >  		dev->out_req->buf = NULL;
> >  		usb_ep_free_request(dev->out_ep, dev->out_req);
> >  		usb_ep_disable(dev->out_ep);
> > 
> > @@ -947,6 +950,7 @@ static int thor_eps_setup(struct usb_function *f)
> > 
> >  	}
> >  	
> >  	dev->out_req = req;
> > 
> > +	out_req_buf = dev->out_req->buf;
> > 
> >  	/* ACM control EP */
> >  	ep = dev->int_ep;
> >  	ep->driver_data = cdev;	/* claim */
> 
> any update on this one?
> 
> Thanks,
> Michal

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-04 11:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-07 11:59 [U-Boot] [PATCH] usb: gadget: f_thor: free the allocated out request buffer Michal Simek
2016-02-04 11:34 ` Michal Simek
2016-02-04 11:41   ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox