Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ee75a17 authored by Saket Saurabh's avatar Saket Saurabh Committed by Mayank Rana
Browse files

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.

CRs-Fixed: 730155
Change-Id: Ifccdfa6068f506bb7dfdc9945b60591da530df8f
Signed-off-by: default avatarSaket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent bc66ea45
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -643,6 +643,9 @@ static int ffs_ep0_open(struct inode *inode, struct file *file)
	ffs_log("state %d setup_state %d flags %lu opened %d", ffs->state,
		ffs->setup_state, ffs->flags, atomic_read(&ffs->opened));

	if (atomic_read(&ffs->opened))
		return -EBUSY;

	if (unlikely(ffs->state == FFS_CLOSING))
		return -EBUSY;