mirror-linux/drivers/usb/phy
Diogo Ivo c69ff68b09 usb: phy: Initialize struct usb_phy list_head
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>
2025-11-26 12:58:46 +01:00
..
Kconfig usb: Remove orphaned UDC drivers 2025-04-11 16:11:25 +02:00
Makefile usb: Remove orphaned UDC drivers 2025-04-11 16:11:25 +02:00
of.c
phy-ab8500-usb.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
phy-am335x-control.c usb: phy: add missing MODULE_DESCRIPTION() macros 2024-06-20 19:18:32 +02:00
phy-am335x-control.h
phy-am335x.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
phy-fsl-usb.c USB: phy: Use str_enable_disable-like helpers 2025-01-15 18:28:13 +01:00
phy-fsl-usb.h
phy-generic.c usb: phy: generic: Use proper helper for property detection 2025-02-03 16:39:56 +01:00
phy-generic.h
phy-gpio-vbus-usb.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
phy-isp1301.c usb: phy: isp1301:: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-10-04 15:12:40 +02:00
phy-keystone.c usb: Switch back to struct platform_driver::remove() 2024-10-04 15:13:03 +02:00
phy-mv-usb.h
phy-mxs-usb.c usb: phy: mxs: silence EPROBE_DEFER error on boot 2025-02-03 16:29:15 +01:00
phy-omap-otg.c
phy-tahvo.c USB: phy: Use str_enable_disable-like helpers 2025-01-15 18:28:13 +01:00
phy-tegra-usb.c usb: phy: tegra: Remove unused functions 2025-06-19 12:26:32 +02:00
phy-twl6030-usb.c usb: phy: twl6030: Fix incorrect type for ret 2025-09-06 15:21:45 +02:00
phy-ulpi-viewport.c
phy-ulpi.c usb: ulpi: Remove unused otg_ulpi_create 2025-03-03 10:23:35 +01:00
phy.c usb: phy: Initialize struct usb_phy list_head 2025-11-26 12:58:46 +01:00