mirror-linux/drivers/usb/gadget/function
Kuen-Han Tsai c529c3730b usb: gadget: u_serial: Fix race condition in TTY wakeup
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-06-19 12:41:13 +02:00
..
Makefile usb: gadget: uvc: add trace of enqueued and completed requests 2024-10-17 08:42:23 +02:00
f_acm.c
f_ecm.c usb: gadget: f_ecm: Add get_status callback 2025-05-01 17:38:41 +02:00
f_eem.c
f_fs.c usb: gadget: f_fs: Remove WARN_ON in functionfs_bind 2024-12-23 18:54:34 +01:00
f_hid.c USB/Thunderbolt changes for 6.16-rc1 2025-06-06 12:45:35 -07:00
f_loopback.c
f_mass_storage.c scsi: usb: Rename the RESERVE and RELEASE constants 2025-02-12 22:20:55 -05:00
f_mass_storage.h USB: gadget: fix up const issue with struct usb_function_instance 2025-05-23 12:31:34 +02:00
f_midi.c USB: gadget: f_midi: f_midi_complete to call queue_work 2025-02-14 09:24:20 +01:00
f_midi2.c ALSA: ump: Fix a typo of snd_ump_stream_msg_device_info 2025-05-11 16:27:55 +02:00
f_ncm.c usb: gadget: Switch to use hrtimer_setup() 2025-02-18 11:19:02 +01:00
f_obex.c
f_phonet.c
f_printer.c
f_rndis.c
f_serial.c usb: gadget: u_serial: Implement remote wakeup capability 2025-04-25 13:42:04 +02:00
f_sourcesink.c
f_subset.c
f_tcm.c usb: potential integer overflow in usbg_make_tpg() 2025-04-15 14:29:33 +02:00
f_uac1.c
f_uac1_legacy.c
f_uac2.c usb: gadget: f_uac2: Fix incorrect setting of bNumEndpoints 2024-12-23 18:50:28 +01:00
f_uvc.c usb: gadget: uvc: rework to enqueue in pump worker from encoded queue 2024-10-17 08:42:22 +02:00
f_uvc.h
g_zero.h
ndis.h
rndis.c
rndis.h
storage_common.c
storage_common.h usb: storage: add a macro for the upper limit of max LUN 2024-12-04 16:33:54 +01:00
tcm.h usb: gadget: f_tcm: Stall on invalid CBW 2024-12-24 08:56:07 +01:00
u_audio.c
u_audio.h
u_ecm.h
u_eem.h
u_ether.c usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails 2025-02-19 15:18:41 +01:00
u_ether.h
u_ether_configfs.h
u_fs.h
u_gether.h
u_hid.h usb: gadget: hid: allow dynamic interval configuration via configfs 2025-05-01 17:30:48 +02:00
u_midi.h
u_midi2.h
u_ncm.h
u_phonet.h
u_printer.h
u_rndis.h
u_serial.c usb: gadget: u_serial: Fix race condition in TTY wakeup 2025-06-19 12:41:13 +02:00
u_serial.h
u_tcm.h
u_uac1.h
u_uac1_legacy.c
u_uac1_legacy.h
u_uac2.h
u_uvc.h
uac_common.h
uvc.h usb: gadget: uvc: set nbuffers to minimum STREAMING_MIN_BUFFERS in uvc_queue_setup 2024-10-17 08:42:23 +02:00
uvc_configfs.c
uvc_configfs.h usb: gadget: uvc: Avoid -Wflex-array-member-not-at-end warnings 2025-04-11 16:08:33 +02:00
uvc_queue.c usb: gadget: uvc: drop vb2_ops_wait_prepare/finish 2025-02-03 16:28:42 +01:00
uvc_queue.h usb: gadget: uvc: set req_length based on payload by nreqs instead of req_size 2024-10-17 08:42:22 +02:00
uvc_trace.c usb: gadget: uvc: add trace of enqueued and completed requests 2024-10-17 08:42:23 +02:00
uvc_trace.h usb: gadget: uvc: add trace of enqueued and completed requests 2024-10-17 08:42:23 +02:00
uvc_v4l2.c usb: gadget: uvc: dont call usb_composite_setup_continue when not streaming 2024-10-17 08:42:23 +02:00
uvc_v4l2.h
uvc_video.c usb: gadget: uvc: Fix unstarted kthread worker 2025-02-14 09:26:00 +01:00
uvc_video.h