mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-09-21 11:53:01 +00:00
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. CRs-Fixed: 730155 Change-Id: Ifccdfa6068f506bb7dfdc9945b60591da530df8f Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
This commit is contained in:
parent
0b5fe7577d
commit
ff579867a0
|
@ -699,6 +699,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);
|
||||
|
||||
|
@ -1406,9 +1409,15 @@ 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);
|
||||
if (test_and_clear_bit(FFS_FL_CALL_CLOSED_CALLBACK, &ffs->flags))
|
||||
functionfs_closed_callback(ffs);
|
||||
|
||||
/* Dump ffs->gadget and ffs->flags */
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue