gadget: f_thor: Fix memory leaks of usb request and its buffer
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 25 May 2018 05:21:01 +0000 (14:21 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 20 Oct 2020 06:13:47 +0000 (15:13 +0900)
There are memory leaks of usb request and its buffer for ep0,
in_ep, and out ep. Fix memory leaks of usb request and its buffer.

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
[sw0312.kim: fix conflict about int_ep from thor_eps_setup()]

Change-Id: I606d039d53847d0e0850c5bcbceca451bdbb1c02

drivers/usb/gadget/f_thor.c

index 884eb1b..b2a80b0 100644 (file)
@@ -1020,12 +1020,16 @@ static int thor_eps_setup(struct usb_function *f)
 
        result = usb_ep_enable(ep, d);
        if (result)
-               goto err;
+               goto err_free_out_req;
 
        ep->driver_data = cdev; /* claim */
 
        return 0;
 
+ err_free_out_req:
+       usb_ep_free_request(dev->out_ep, dev->out_req);
+       dev->out_req = NULL;
+
  err_disable_out_ep:
        usb_ep_disable(dev->out_ep);