summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorSaket Saurabh <ssaurabh@codeaurora.org>2016-01-28 11:56:10 -0800
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-22 11:10:05 -0700
commit5cd572ca8d3474613d4562e1e9cb533c8ba65842 (patch)
treeeafb22edda7bcff9887255326b7b9b9f7439205f /drivers/usb
parent9d89a6599da09d4289e69f29c96a37e4aa8dece1 (diff)
usb: gadget: f_fs: Allow only one adb daemon perform device open
As part of ffs_ep0_open(), atomic variable ffs.opened is set and as part of ffs_ep0_release() it is cleared. Also as part of release operation, in ffs_data_clear() ffs->gadget is set to NULL. If two adb daemons are running in parallel, then BUG ON is observed as part of release operation as ffs->gadget is not set to NULL. To fix the issue add check for ffs->opened to allow only one adb daemon perform device open. This ensures open and release operation are performed in serialized way and avoids any race. Also add debug print for dumping the ffs gadget. Change-Id: Ifccdfa6068f506bb7dfdc9945b60591da530df8f Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org> Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/function/f_fs.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 5032aae7e6e3..4349fe73e23f 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -539,6 +539,9 @@ static int ffs_ep0_open(struct inode *inode, struct file *file)
if (unlikely(ffs->state == FFS_CLOSING))
return -EBUSY;
+ if (atomic_read(&ffs->opened))
+ return -EBUSY;
+
file->private_data = ffs;
ffs_data_opened(ffs);
@@ -1524,8 +1527,13 @@ static void ffs_data_clear(struct ffs_data *ffs)
{
ENTER();
+ pr_debug("%s: ffs->gadget= %p, ffs->flags= %lu\n",
+ __func__, ffs->gadget, ffs->flags);
ffs_closed(ffs);
+ if (ffs->gadget)
+ pr_err("%s: ffs->gadget= %p, ffs->flags= %lu\n",
+ __func__, ffs->gadget, ffs->flags);
BUG_ON(ffs->gadget);
if (ffs->epfiles)