From 4f06539ffa1948f1d2623f549136c87e33dc1d75 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Thu, 3 May 2012 12:58:49 +0200 Subject: [PATCH] f_fs: ffs_func_free: cleanup requests allocated by autoconfig functionfs was leaking request objects created by autoconfig. Signed-off-by: Peter Korsgaard Signed-off-by: Felipe Balbi --- drivers/usb/gadget/f_fs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index f52cb1ae45d9..1d4c535671a7 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -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); -- 2.20.1