From: Peter Korsgaard Date: Thu, 3 May 2012 10:58:49 +0000 (+0200) Subject: f_fs: ffs_func_free: cleanup requests allocated by autoconfig X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4f06539ffa1948f1d2623f549136c87e33dc1d75;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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);