linux-imx/drivers/net/phy
Wei Fang 19ce6042dd net: phy: clear phydev->devlink when the link is deleted
There is a potential crash issue when disabling and re-enabling the
network port. When disabling the network port, phy_detach() calls
device_link_del() to remove the device link, but it does not clear
phydev->devlink, so phydev->devlink is not a NULL pointer. Then the
network port is re-enabled, but if phy_attach_direct() fails before
calling device_link_add(), the code jumps to the "error" label and
calls phy_detach(). Since phydev->devlink retains the old value from
the previous attach/detach cycle, device_link_del() uses the old value,
which accesses a NULL pointer and causes a crash. The simplified crash
log is as follows.

[   24.702421] Call trace:
[   24.704856]  device_link_put_kref+0x20/0x120
[   24.709124]  device_link_del+0x30/0x48
[   24.712864]  phy_detach+0x24/0x168
[   24.716261]  phy_attach_direct+0x168/0x3a4
[   24.720352]  phylink_fwnode_phy_connect+0xc8/0x14c
[   24.725140]  phylink_of_phy_connect+0x1c/0x34

Therefore, phydev->devlink needs to be cleared when the device link is
deleted.

Fixes: bc66fa87d4 ("net: phy: Add link between phy dev and mac dev")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20250523083759.3741168-1-wei.fang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2025-05-29 15:21:22 +08:00
..
mscc net: phy: mscc: configure in-band auto-negotiation for VSC8514 2023-10-30 17:16:59 +08:00
adin.c
adin1100.c
amd.c
aquantia_hwmon.c
aquantia_main.c LF-10639-3 net: phy: aquantia: enable LEDs to show the link state 2023-11-21 18:05:12 +08:00
aquantia.h
at803x.c net: phy: at803x: fix passing the wrong reference for config_intr 2024-02-05 20:14:22 +00:00
ax88796b.c
bcm-cygnus.c
bcm-phy-lib.c
bcm-phy-lib.h
bcm-phy-ptp.c
bcm7xxx.c net: phy: bcm7xxx: Add missing 16nm EPHY statistics 2023-10-18 18:13:13 -07:00
bcm63xx.c
bcm87xx.c
bcm54140.c
bcm84881.c net: phy: bcm84881: move the in-band capability check where it belongs 2023-10-30 17:16:59 +08:00
broadcom.c net: phy: broadcom: stub c45 read/write for 54810 2023-08-15 18:53:43 -07:00
cicada.c
cortina.c
davicom.c
dp83tc811.c
dp83td510.c net: phy: dp83td510: fix kernel stall during netboot in DP83TD510E PHY driver 2023-06-22 19:43:55 -07:00
dp83640_reg.h
dp83640.c dp83640: Use list_for_each_entry() helper 2023-08-23 09:39:15 +01:00
dp83822.c net: phy: dp83822: Fix RGMII TX delay configuration 2024-03-26 18:19:40 -04:00
dp83848.c
dp83867.c
dp83869.c net: phy: dp83869: Fix MII mode failure 2024-05-02 16:32:39 +02:00
et1011c.c
fixed_phy.c net: phy: fixed_phy: add fixed PHY ACPI support 2023-10-30 17:16:54 +08:00
icplus.c
intel-xway.c
Kconfig net: phy: nxp-c45-tja11xx: add TJA1120 support 2023-08-01 21:06:25 -07:00
linkmode.c
lxt.c
Makefile net: phy: mtip_backplane: add a phylib wrapper over the phylink_pcs core 2023-10-30 17:16:59 +08:00
marvell-88q2xxx.c net: phy: marvell-88q2xxx: add driver for the Marvell 88Q2110 PHY 2023-07-20 12:24:06 +02:00
marvell-88x2222.c net: phy/pcs: Explicitly include correct DT includes 2023-07-26 21:55:37 -07:00
marvell.c net: phy: marvell: Add support for offloading LED blinking 2023-08-10 17:35:00 -07:00
marvell10g.c net: phy: marvell10g: fix 88x3310 power up 2023-07-23 11:47:07 +01:00
mdio_bus.c net: mdio: probe non-PHY MDIO devices in ACPI 2023-10-30 17:16:54 +08:00
mdio_device.c
mdio_devres.c
mdio-boardinfo.c
mdio-boardinfo.h
mdio-open-alliance.h
mediatek-ge-soc.c net: phy: mediatek-ge-soc: follow netdev LED trigger semantics 2024-05-02 16:32:37 +02:00
mediatek-ge.c
meson-gxl.c
micrel.c net: phy: micrel: Fix the KSZ9131 MDI-X status issue 2024-08-11 12:47:21 +02:00
microchip_t1.c net: phy: microchip: lan87xx: reinit PHY after cable test 2024-07-18 13:21:12 +02:00
microchip_t1s.c
microchip.c
mii_timestamper.c
motorcomm.c net: phy: motorcomm: Add pad drive strength cfg support 2023-07-24 10:36:45 +01:00
mtip_backplane_phy.c net: phy: mtip_backplane: add a phylib wrapper over the phylink_pcs core 2023-10-30 17:16:59 +08:00
mxl-gpy.c net: phy: mxl-gpy: Remove interrupt mask clearing from config_init 2024-06-27 13:49:07 +02:00
national.c
ncn26000.c
nxp-c45-tja11xx.c net: phy: nxp-c45-tja11xx: reset PCS if the link goes down 2023-08-01 21:06:26 -07:00
nxp-cbtx.c
nxp-tja11xx.c LF-9849-4: net: phy: tja11xx: do not enable both REFCLK_IN and OUT when initializing 2023-10-30 11:57:36 -05:00
phy_device.c net: phy: clear phydev->devlink when the link is deleted 2025-05-29 15:21:22 +08:00
phy_led_triggers.c
phy-c45.c net: phy: c45: detect the BASE-T1 speed from the ability register 2023-07-20 12:24:06 +02:00
phy-core.c net: phylink: add support for managed = "c73" 2023-10-30 17:16:56 +08:00
phy.c net: phylink: explicitly configure in-band autoneg for PHYs that support it 2023-10-30 17:16:59 +08:00
phylink.c net: phylink: suppress pcs->ops->pcs_get_state() calls after phylink_stop() 2024-07-31 18:45:47 +03:00
qsemi.c
realtek.c This is the 6.6.51 stable release 2024-09-24 11:49:41 +08:00
rockchip.c
sfp-bus.c net: sfp-bus: fix SFP mode detect from bitrate 2024-06-16 13:47:30 +02:00
sfp.c net: sfp: add quirk for ATS SFP-GE-T 1000Base-TX module 2024-06-27 13:49:02 +02:00
sfp.h net: sfp: Remove unused function declaration sfp_link_configure() 2023-08-07 08:53:55 +01:00
smsc.c net: phy: smsc: add WoL support to LAN8740/LAN8742 PHYs 2023-07-26 21:24:40 -07:00
spi_ks8995.c
ste10Xp.c
stubs.c net: phy: provide phylib stubs for hardware timestamping operations 2023-08-02 19:11:06 -07:00
swphy.c net: phy: add 10G fixed-link support 2023-10-30 17:16:53 +08:00
swphy.h
teranetics.c
uPD60620.c
vitesse.c net: phy: vitesse: repair vsc73xx autonegotiation 2024-09-18 19:24:05 +02:00
xilinx_gmii2rgmii.c