linux-yocto/drivers/usb/gadget
Kuen-Han Tsai ee8d688e2b usb: gadget: u_serial: Fix race condition in TTY wakeup
commit c529c3730b upstream.

A race condition occurs when gs_start_io() calls either gs_start_rx() or
gs_start_tx(), as those functions briefly drop the port_lock for
usb_ep_queue(). This allows gs_close() and gserial_disconnect() to clear
port.tty and port_usb, respectively.

Use the null-safe TTY Port helper function to wake up TTY.

Example
  CPU1:			      CPU2:
  gserial_connect() // lock
  			      gs_close() // await lock
  gs_start_rx()     // unlock
  usb_ep_queue()
  			      gs_close() // lock, reset port.tty and unlock
  gs_start_rx()     // lock
  tty_wakeup()      // NPE

Fixes: 35f95fd7f2 ("TTY: usb/u_serial, use tty from tty_port")
Cc: stable <stable@kernel.org>
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Reviewed-by: Prashanth K <prashanth.k@oss.qualcomm.com>
Link: https://lore.kernel.org/linux-usb/20240116141801.396398-1-khtsai@google.com/
Link: https://lore.kernel.org/r/20250617050844.1848232-2-khtsai@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-17 18:32:08 +02:00
..
function usb: gadget: u_serial: Fix race condition in TTY wakeup 2025-07-17 18:32:08 +02:00
legacy
udc usb: gadget: tegra-xudc: ACK ST_RC after clearing CTRL_RUN 2025-05-18 08:21:24 +02:00
composite.c usb: gadget: Check bmAttributes only if configuration is valid 2025-03-13 12:53:21 +01:00
config.c
configfs.c
configfs.h
epautoconf.c
functions.c
Kconfig
Makefile
u_f.c
u_f.h
u_os_desc.h
usbstring.c