]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: gadget: phonet: free requests in pn_bind()'s error path
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Mon, 22 Oct 2012 20:15:04 +0000 (22:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Jan 2013 17:06:53 +0000 (09:06 -0800)
commit d0eca719dd11ad0619e8dd6a1f3eceb95b0216dd upstream.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/f_phonet.c

index 965a6293206acc5bb52facb12d8acf50d3c3c6a2..16512f921bc090f5739cf668d6bec50c12e7112c 100644 (file)
@@ -531,7 +531,7 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
 
                req = usb_ep_alloc_request(fp->out_ep, GFP_KERNEL);
                if (!req)
-                       goto err;
+                       goto err_req;
 
                req->complete = pn_rx_complete;
                fp->out_reqv[i] = req;
@@ -540,14 +540,18 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
        /* Outgoing USB requests */
        fp->in_req = usb_ep_alloc_request(fp->in_ep, GFP_KERNEL);
        if (!fp->in_req)
-               goto err;
+               goto err_req;
 
        INFO(cdev, "USB CDC Phonet function\n");
        INFO(cdev, "using %s, OUT %s, IN %s\n", cdev->gadget->name,
                fp->out_ep->name, fp->in_ep->name);
        return 0;
 
+err_req:
+       for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++)
+               usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
 err:
+
        if (fp->out_ep)
                fp->out_ep->driver_data = NULL;
        if (fp->in_ep)