linux/drivers/usb
Marek Vasut dea99705bc usb: typec: mux: Fix typec_switch_match()
The fwnode_typec_switch_get() sporadically returns NULL instead of an
-EPROBE_DEFER for orientation-switch described in DT. This makes it
impossible to discern whether the DT does describe an orientation-switch
which did not probe yet, or whether the DT does not describe the switch.
This happens with gpio-sbu-mux connected to an I2C GPIO expander.

The class_find_device() on typec_switch_match() may return NULL in case
the mux did not probe just yet early on boot. The sw_devs[] array can be
empty on boot as well. If these two conditions occur, then the conditional
if (to_typec_switch_dev(dev) == sw_devs[i]) evaluates to true and the match
function returns NULL, which propagates to fwnode_typec_switch_get() which
makes it look as if the orientation-switch was not described in DT.

This is incorrect, because the mux driver will probe a bit later on, but
at that point, the caller of fwnode_typec_switch_get() already got the
NULL return value. The NULL return value also does not trigger IS_ERR(),
therefore the caller driver interprets this as if the orientation-switch
is not described in DT, and does not return -EPROBE_DEFER to try again,
even if it should.

Fix this by checking the class_find_device() return value, and return
-EPROBE_DEFER if it is NULL right away. If the return value is not NULL,
perform the deduplication test, and if that test passes, consider the
return value to be already non-NULL.

Fixes: a53b4f9c51 ("usb: typec: mux: avoid duplicated orientation switches")
Cc: stable <stable@kernel.org>
Signed-off-by: Marek Vasut <marex@nabladev.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: Jens Glathe <jens.glathe@oldschoolsolutions.biz>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://patch.msgid.link/20260817182302.146546-1-marex@nabladev.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-09-01 16:31:23 +02:00
..
atm Including fixes from Bluetooth, IPSec and Netfilter. 2026-08-27 13:53:43 -07:00
c67x00 USB: c67x00: fix use-after-free in c67x00_add_iso_urb() 2026-08-14 10:49:00 +09:00
cdns3 Merge 7.2-rc7 into usb-next 2026-08-14 10:17:11 +09:00
chipidea USB / Thunderbolt changes for 7.3-rc1 2026-08-25 10:44:46 -07:00
class Merge 7.2-rc3 into usb-next 2026-07-13 07:09:28 +02:00
common USB: ulpi: fix memory leak on registration failure 2026-06-25 15:11:27 +01:00
core usb: usbfs: fix use-after-free of usb_device in usbdev_release() 2026-08-14 10:49:38 +09:00
dwc2 usb: dwc2: gadget: Exit partial power down state when changing USB pull-up 2026-08-14 10:48:41 +09:00
dwc3 usb: dwc3: gadget: Fix use-after-free in dwc3_gadget_free_endpoints due to race condition 2026-08-14 10:49:25 +09:00
early usb: early: xhci-dbc: Fix early_ioremap leak 2025-07-07 11:04:46 +02:00
fotg210 usb: free iso schedules on failed submit 2026-07-08 13:30:38 +02:00
gadget usb: gadget: uvc: fix dangling pointers in uvc_function_bind() and uvc_function_unbind() 2026-08-14 10:49:48 +09:00
host xhci: fix lost bounce buffers on TDs spanning several ring segments 2026-08-31 11:43:00 +02:00
image usb: image: mdc800: change kmalloc() to kzalloc() 2026-09-01 16:31:07 +02:00
isp1760 Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
misc usb: usbtest: disable dynamic ID support 2026-08-14 10:49:12 +09:00
mon Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
mtu3 Merge 7.2-rc3 into usb-next 2026-07-13 07:09:28 +02:00
musb USB / Thunderbolt changes for 7.3-rc1 2026-08-25 10:44:46 -07:00
phy USB: phy: fsl-usb: fix missing static keywords 2026-07-17 17:54:18 +02:00
renesas_usbhs usb: renesas_usbhs: Fix power-off ordering on unbind 2026-07-10 15:56:24 +02:00
roles usb: roles: get usb role switch from parent only for usb-b-connector 2026-03-11 16:22:22 +01:00
serial USB serial updates for 7.3-rc1 2026-08-14 10:25:23 +09:00
storage USB: storage: add NO_ATA_1X quirk for Longmai USB Key 2026-07-16 17:11:02 +02:00
typec usb: typec: mux: Fix typec_switch_match() 2026-09-01 16:31:23 +02:00
usbip usbip: vudc: fix NULL deref in vep_dequeue() 2026-07-08 13:29:31 +02:00
Kconfig
Makefile usb: cdns3: Add USBSSP platform driver support 2026-04-27 05:14:18 -06:00
usb-skeleton.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00