linux/drivers/usb
Hans de Goede fbfe493874 usb: ucsi: Fix ucsi->connector race
commit 0482c34ec6 upstream.

ucsi_init() which runs from a workqueue sets ucsi->connector and
on an error will clear it again.

ucsi->connector gets dereferenced by ucsi_resume(), this checks for
ucsi->connector being NULL in case ucsi_init() has not finished yet;
or in case ucsi_init() has failed.

ucsi_init() setting ucsi->connector and then clearing it again on
an error creates a race where the check in ucsi_resume() may pass,
only to have ucsi->connector free-ed underneath it when ucsi_init()
hits an error.

Fix this race by making ucsi_init() store the connector array in
a local variable and only assign it to ucsi->connector on success.

Fixes: bdc62f2bae ("usb: typec: ucsi: Simplified registration and I/O API")
Cc: stable@vger.kernel.org
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230308154244.722337-3-hdegoede@redhat.com
Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-04-06 12:10:58 +02:00
..
atm
c67x00
cdns3 usb: cdnsp: changes PCI Device ID to fix conflict with CNDS3 driver 2023-03-30 12:49:24 +02:00
chipidea usb: chipidea: core: fix possible concurrent when switch role 2023-03-30 12:49:24 +02:00
class
common USB: ULPI: fix memory leak with using debugfs_lookup() 2023-03-11 13:55:36 +01:00
core
dwc2 usb: dwc2: fix a devres leak in hw_enable upon suspend resume 2023-03-30 12:49:22 +02:00
dwc3 usb: dwc3: gadget: Add 1ms delay after end transfer command without IOC 2023-03-30 12:49:25 +02:00
early
gadget usb: gadget: u_audio: don't let userspace block driver unbind 2023-03-30 12:49:22 +02:00
host usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math 2023-03-11 13:55:38 +01:00
image
isp1760
misc usb: misc: onboard-hub: add support for Microchip USB2517 USB 2.0 hub 2023-03-30 12:49:22 +02:00
mon
mtu3
musb
phy
renesas_usbhs
roles
serial
storage uas: Add US_FL_NO_REPORT_OPCODES for JMicron JMS583Gen 2 2023-03-30 12:49:14 +02:00
typec usb: ucsi: Fix ucsi->connector race 2023-04-06 12:10:58 +02:00
usbip
Kconfig
Makefile
usb-skeleton.c