linux-imx/drivers/net
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
..
appletalk
arcnet
bonding bonding: change ipsec_lock from spin lock to mutex 2024-09-04 13:28:27 +02:00
caif
can This is the 6.6.51 stable release 2024-09-24 11:49:41 +08:00
dsa This is the 6.6.52 stable release 2024-09-24 11:50:01 +08:00
ethernet LF-14922 net: enetc: Fix null pointer accces in fsl-netc-prb-ierb driver probe 2025-03-26 17:14:17 +02:00
fddi
fjes
hamradio
hippi
hyperv
ieee802154
ipa
ipvlan ipvlan: Dont Use skb->sk in ipvlan_process_v{4,6}_outbound 2024-06-12 11:12:59 +02:00
mctp net: mctp-serial: Fix missing escapes on transmit 2024-09-12 11:11:28 +02:00
mdio
netdevsim
pcs LF-12325 pcs: xpcs: remove the unnecessary delays 2024-10-15 17:02:05 +08:00
phy net: phy: clear phydev->devlink when the link is deleted 2025-05-29 15:21:22 +08:00
plip
ppp pppoe: Fix memory leak in pppoe_sendmsg() 2024-08-19 06:04:27 +02:00
pse-pd
slip
team
thunderbolt
usb usbnet: ipheth: fix carrier detection in modes 1 and 4 2024-09-18 19:24:05 +02:00
vmxnet3 vmxnet3: disable rx data ring on dma allocation failure 2024-06-21 14:38:15 +02:00
vxlan vxlan: Fix regression when dropping packets due to invalid src addresses 2024-06-21 14:38:17 +02:00
wan
wireguard wireguard: send: annotate intentional data race in checking empty queue 2024-07-18 13:21:23 +02:00
wireless wifi: mt76: mt7921: fix NULL pointer access in mt7921_ipv6_addr_change 2024-09-18 19:24:05 +02:00
wwan net: wwan: iosm: Fix tainted pointer delete is case of region creation fail 2024-06-21 14:38:18 +02:00
xen-netback kthread: add kthread_stop_put 2024-06-12 11:12:52 +02:00
amt.c
bareudp.c bareudp: Fix device stats updates. 2024-09-12 11:11:34 +02:00
dummy.c
eql.c
geneve.c geneve: Fix incorrect inner network header offset when innerprotoinherit is set 2024-06-21 14:38:33 +02:00
gtp.c gtp: fix a potential NULL pointer dereference 2024-09-04 13:28:27 +02:00
ifb.c net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers). 2022-10-28 20:13:54 -07:00
imx-shmem-net.c
ivshmem-net.c
Kconfig
LICENSE.SRC
loopback.c
macsec.c
macvlan.c
macvtap.c
Makefile This is the 6.6.34 stable release 2024-06-18 17:16:08 +08:00
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c net: netconsole: Disable target before netpoll cleanup 2024-08-03 08:54:13 +02:00
nlmon.c
ntb_netdev.c net: ntb_netdev: Move ntb_netdev_rx_handler() to call netif_rx() from __netif_rx() 2024-07-11 12:49:13 +02:00
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c tap: add missing verification for short frame 2024-07-27 11:34:11 +02:00
tun.c tun: add missing verification for short frame 2024-07-27 11:34:10 +02:00
veth.c
virtio_net.c virtio_net: Fix napi_skb_cache_put warning 2024-09-08 07:54:49 +02:00
vrf.c
vsockmon.c
xen-netfront.c