android_kernel_motorola_sm6375/drivers/usb
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Uttkarsh Aggarwal d5f1838815 usb: gadget: f_fs: Add unbind event before functionfs_unbind
commit efb6b535207395a5c7317993602e2503ca8cb4b3 upstream.

While exercising the unbind path, with the current implementation
the functionfs_unbind would be calling which waits for the ffs->mutex
to be available, however within the same time ffs_ep0_read is invoked
& if no setup packets are pending, it will invoke function
wait_event_interruptible_exclusive_locked_irq which by definition waits
for the ev.count to be increased inside the same mutex for which
functionfs_unbind is waiting.
This creates deadlock situation because the functionfs_unbind won't
get the lock until ev.count is increased which can only happen if
the caller ffs_func_unbind can proceed further.

Following is the illustration:

	CPU1				CPU2

ffs_func_unbind()		ffs_ep0_read()
				mutex_lock(ffs->mutex)
				wait_event(ffs->ev.count)
functionfs_unbind()
  mutex_lock(ffs->mutex)
  mutex_unlock(ffs->mutex)

ffs_event_add()

<deadlock>

Fix this by moving the event unbind before functionfs_unbind
to ensure the ev.count is incrased properly.

Fixes: 6a19da111057 ("usb: gadget: f_fs: Prevent race during ffs_ep0_queue_wait")
Cc: stable <stable@kernel.org>
Signed-off-by: Uttkarsh Aggarwal <quic_uaggarwa@quicinc.com>
Link: https://lore.kernel.org/r/20230525092854.7992-1-quic_uaggarwa@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-09 10:29:00 +02:00
..
atm
c67x00
cdns3 usb: cdns3: Fix issue with using incorrect PCI device function 2023-04-05 11:16:40 +02:00
chipidea usb: chipidea: fix missing goto in ci_hdrc_probe 2023-05-17 11:35:49 +02:00
class USB: usbtmc: Fix direction for 0-length ioctl control messages 2023-05-30 12:44:06 +01:00
common Revert "usb: ulpi: defer ulpi_register on ulpi_read_id timeout" 2023-01-18 11:42:06 +01:00
core USB: core: Add routines for endpoint checks in old drivers 2023-05-30 12:44:10 +01:00
dwc2 usb: dwc2: fix wrong order of phy_power_on and phy_init 2022-09-15 12:04:52 +02:00
dwc3 usb: dwc3: debugfs: Resume dwc3 before accessing registers 2023-05-30 12:44:06 +01:00
early
gadget usb: gadget: f_fs: Add unbind event before functionfs_unbind 2023-06-09 10:29:00 +02:00
host USB: UHCI: adjust zhaoxin UHCI controllers OverCurrent bit value 2023-05-30 12:44:06 +01:00
image
isp1760
misc USB: sisusbvga: Add endpoint checks 2023-05-30 12:44:10 +01:00
mon usb: mon: make mmapped memory read only 2022-10-15 07:54:38 +02:00
mtu3 usb: mtu3: fix kernel panic at qmu transfer done irq handler 2023-05-17 11:35:49 +02:00
musb usb: musb: remove extra check in musb_gadget_vbus_draw 2023-01-18 11:40:49 +01:00
phy
renesas_usbhs
roles usb: roles: fix of node refcount leak in usb_role_switch_is_parent() 2023-01-18 11:41:24 +01:00
serial USB: serial: option: add UNISOC vendor and TOZED LT70C product 2023-05-17 11:35:31 +02:00
storage usb-storage: fix deadlock when a scsi command timeouts more than once 2023-05-30 12:44:06 +01:00
typec usb: typec: altmodes/displayport: fix pin_assignment_show 2023-05-30 12:44:06 +01:00
usbip
Kconfig
Makefile
usb-skeleton.c