f_fs: ffs_func_free: cleanup requests allocated by autoconfig
authorPeter Korsgaard <peter.korsgaard@barco.com>
Thu, 3 May 2012 10:58:49 +0000 (12:58 +0200)
committerFelipe Balbi <balbi@ti.com>
Fri, 4 May 2012 12:53:09 +0000 (15:53 +0300)
functionfs was leaking request objects created by autoconfig.

Signed-off-by: Peter Korsgaard <peter.korsgaard@barco.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/f_fs.c

index f52cb1ae45d9a5ab27a46cb40b34cdb94e93a484..1d4c535671a7e68a7308db573408be5694be18da 100644 (file)
@@ -1473,8 +1473,22 @@ static int functionfs_bind_config(struct usb_composite_dev *cdev,
 
 static void ffs_func_free(struct ffs_function *func)
 {
+       struct ffs_ep *ep         = func->eps;
+       unsigned count            = func->ffs->eps_count;
+       unsigned long flags;
+
        ENTER();
 
+       /* cleanup after autoconfig */
+       spin_lock_irqsave(&func->ffs->eps_lock, flags);
+       do {
+               if (ep->ep && ep->req)
+                       usb_ep_free_request(ep->ep, ep->req);
+               ep->req = NULL;
+               ++ep;
+       } while (--count);
+       spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
+
        ffs_data_put(func->ffs);
 
        kfree(func->eps);