Skip to contentSkip to conversation

usb: gadget: f_thor: free the allocated out request buffer

PATCH Superseded Michal Simek 3 participants 3 messages Dec 7, 2015 – Feb 4, 2016 USB

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: f_thor: free the allocated out request buffer

From: Siva Durga Prasad Paladugu <[email protected]>

Fix the memory leak by freeing the allocated out request buffer

---

 drivers/usb/gadget/f_thor.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/gadget/f_thor.c +4 -0
index a60e9487e774..75b72902c9d5 100644
@@ -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 */
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 usb: gadget: f_thor: free the allocated out request buffer

Hi guys,

Quoted 34 lines · Michal Simek

From: Siva Durga Prasad Paladugu <[email protected]>

Fix the memory leak by freeing the allocated out request buffer

---

 drivers/usb/gadget/f_thor.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/gadget/f_thor.c +3 -0
index a60e9487e774..75b72902c9d5 100644
@@ -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);

drivers/usb/gadget/f_thor.c static int thor_eps_setup(struct usb_function *f) · line 956

Quoted 7 lines
drivers/usb/gadget/f_thor.c +1 -0
@@ -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

Signature · 14 lines
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>
#2 lore raw

PATCH 1/1 usb: gadget: f_thor: free the allocated out request buffer

Quoted 30 lines · Michal Simek

Hi guys,

Quoted 27 lines · Michal Simek

From: Siva Durga Prasad Paladugu <[email protected]>

Fix the memory leak by freeing the allocated out request buffer

---

 drivers/usb/gadget/f_thor.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/gadget/f_thor.c +1 -0
index a60e9487e774..75b72902c9d5 100644
@@ -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)
{

Quoted 8 lines

drivers/usb/gadget/f_thor.c static void thor_func_disable(struct usb_function *f) · line 898

Quoted 8 lines
drivers/usb/gadget/f_thor.c +2 -0
@@ -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.

Quoted 12 lines
Quoted 12 lines
drivers/usb/gadget/f_thor.c +0 -0
 		dev->out_req->buf = NULL;
drivers/usb/gadget/f_thor.c +1 -0
 		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;
 
Quoted 8 lines

drivers/usb/gadget/f_thor.c static int thor_eps_setup(struct usb_function *f) · line 956

Quoted 3 lines
drivers/usb/gadget/f_thor.c +0 -0
 	/* ACM control EP */
 	ep = dev->int_ep;
 	ep->driver_data = cdev;	/* claim */

any update on this one?

Thanks,
Michal

Best regards,
Marek Vasut