linux/drivers/usb
Diogo Ivo ce205e4807 usb: phy: Initialize struct usb_phy list_head
commit c69ff68b09 upstream.

As part of the registration of a new 'struct usb_phy' with the USB PHY core
via either usb_add_phy(struct usb_phy *x, ...) or usb_add_phy_dev(struct
usb_phy *x) these functions call list_add_tail(&x->head, phy_list) in
order for the new instance x to be stored in phy_list, a static list
kept internally by the core.

After 7d21114dc6 ("usb: phy: Introduce one extcon device into usb phy")
when executing either of the registration functions above it is possible
that usb_add_extcon() fails, leading to either function returning before
the call to list_add_tail(), leaving x->head uninitialized.

Then, when a driver tries to undo the failed registration by calling
usb_remove_phy(struct usb_phy *x) there will be an unconditional call to
list_del(&x->head) acting on an uninitialized variable, and thus a
possible NULL pointer dereference.

Fix this by initializing x->head before usb_add_extcon() has a
chance to fail. Note that this was not needed before 7d21114dc6 since
list_add_phy() was executed unconditionally and it guaranteed that x->head
was initialized.

Fixes: 7d21114dc6 ("usb: phy: Introduce one extcon device into usb phy")
Cc: stable <stable@kernel.org>
Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Link: https://patch.msgid.link/20251121-diogo-smaug_typec-v2-1-5c37c1169d57@tecnico.ulisboa.pt
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-01-19 13:09:40 +01:00
..
atm usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init() 2025-08-28 16:24:27 +02:00
c67x00 usb/c67x00: Replace tasklet with work 2021-01-26 18:36:37 +01:00
cdns3 usb: cdns3: Fix double resource release in cdns3_pci_probe 2025-12-07 06:09:35 +09:00
chipidea usb: chipidea: add USB PHY event 2025-08-28 16:24:05 +02:00
class cdc-acm: fix race between initial clearing halt and open 2025-08-28 16:24:26 +02:00
common usb: common: usb-conn-gpio: use a unique name for usb connector device 2025-07-10 15:57:33 +02:00
core USB: Fix descriptor count when handling invalid MBIM extended descriptor 2026-01-19 13:09:22 +01:00
dwc2 usb: dwc2: fix hang during suspend if set as peripheral 2026-01-19 13:09:32 +01:00
dwc3 usb: dwc3: Fix race condition between concurrent dwc3_remove_requests() call paths 2025-12-07 06:09:35 +09:00
early usb: early: xhci-dbc: Fix early_ioremap leak 2025-08-28 16:24:06 +02:00
gadget usb: gadget: tegra-xudc: Always reinitialize data toggle when clear halt 2026-01-19 13:09:40 +01:00
host xhci: dbgtty: Fix data corruption when transmitting data form DbC to host 2025-12-07 06:09:35 +09:00
image USB: microtek: use set_host_byte() 2020-09-16 12:42:10 +02:00
isp1760 usb: isp1760: Fix out-of-bounds array access 2022-06-09 10:22:27 +02:00
misc usb: chaoskey: fix locking for O_NONBLOCK 2026-01-19 13:09:31 +01:00
mon usb: mon: Increase BUFF_MAX to 64 MiB to support multi-MB URBs 2025-12-07 06:09:22 +09:00
mtu3 usb: mtu3: fix kernel panic at qmu transfer done irq handler 2023-05-11 23:00:33 +09:00
musb usb: musb: omap2430: fix device leak at unbind 2025-08-28 16:24:32 +02:00
phy usb: phy: Initialize struct usb_phy list_head 2026-01-19 13:09:40 +01:00
renesas_usbhs usb: renesas_usbhs: Fix synchronous external abort on unbind 2025-12-07 06:09:36 +09:00
roles usb: roles: set switch registered flag early on 2025-03-13 12:50:37 +01:00
serial USB: serial: kobil_sct: fix TIOCMBIS and TIOCMBIC 2026-01-19 13:09:20 +01:00
storage usb: uas: fix urb unmapping issue when the uas device is remove during ongoing data transfer 2025-12-07 06:09:35 +09:00
typec usb: typec: ucsi: psy: Set max current to zero when disconnected 2025-12-07 06:09:36 +09:00
usbip usb: vhci-hcd: Prevent suspending virtually attached devices 2025-10-19 16:21:36 +02:00
Kconfig usb: remove reference to deleted config STB03xxx 2021-08-18 15:32:19 +02:00
Makefile usb: host: remove line for obsolete config USB_HWA_HCD 2021-08-18 15:32:19 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00