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 net: appletalk: remove Apple/Farallon LocalTalk PC support 2022-05-11 13:08:38 +01:00
arcnet arcnet: restoring support for multiple Sohard Arcnet cards 2023-12-13 18:45:05 +01:00
bonding bonding: change ipsec_lock from spin lock to mutex 2024-09-04 13:28:27 +02:00
caif tty: use u8 for flags 2023-08-11 21:12:45 +02:00
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 fjes: fix memleaks in fjes_hw_setup 2024-01-31 16:19:05 -08:00
hamradio tty: use u8 for flags 2023-08-11 21:12:45 +02:00
hippi net: hippi: Add missing pci_disable_device() in rr_init_one() 2022-09-26 13:22:39 -07:00
hyperv hv_netvsc: Don't free decrypted memory 2024-05-17 12:02:17 +02:00
ieee802154
ipa net: ipa: don't overrun IPA suspend interrupt registers 2024-03-01 13:35:08 +01:00
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 net: explicitly check in of_phy_is_fixed_link() for managed = "in-band-status" 2023-10-30 17:16:56 +08:00
netdevsim netdevsim: avoid potential loop in nsim_dev_trap_report_work() 2024-02-16 19:10:47 +01:00
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 net: plip: don't call kfree_skb/dev_kfree_skb() under spin_lock_irq() 2022-12-07 20:10:47 -08:00
ppp pppoe: Fix memory leak in pppoe_sendmsg() 2024-08-19 06:04:27 +02:00
pse-pd net: pse-pd: PSE_REGULATOR should depend on REGULATOR 2022-10-05 20:32:28 -07:00
slip tty: use u8 for flags 2023-08-11 21:12:45 +02:00
team team: Fix use-after-free when an option instance allocation fails 2023-12-20 17:02:02 +01:00
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 amt: do not use overwrapped cb area 2024-01-25 15:35:56 -08:00
bareudp.c bareudp: Fix device stats updates. 2024-09-12 11:11:34 +02:00
dummy.c net: add netdev_lockdep_set_classes() to virtual drivers 2024-04-13 13:07:30 +02:00
eql.c net: rename reference+tracking helpers 2022-06-09 21:52:55 -07:00
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 SCF-7618 net: imx-shmem-net: Fix build break due to kernel upgrade 2023-10-30 15:52:10 +08:00
ivshmem-net.c LF-7429 net: ivshmem-net: handle softirq after napi_schedule 2023-10-30 15:52:11 +08:00
Kconfig MLK-25346: net: add imx-shmem-net driver 2023-10-30 15:52:10 +08:00
LICENSE.SRC Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
loopback.c net: add netdev_lockdep_set_classes() to virtual drivers 2024-04-13 13:07:30 +02:00
macsec.c macsec: Detect if Rx skb is macsec-related for offloading devices that update md_dst 2024-05-02 16:32:50 +02:00
macvlan.c macvlan: Don't propagate promisc change to lower dev in passthru 2023-11-28 17:19:54 +00:00
macvtap.c
Makefile This is the 6.6.34 stable release 2024-06-18 17:16:08 +08:00
mdio.c net: mdio: Correct function name mdio45_links_ok() in comment 2021-03-29 13:42:44 -07:00
mhi_net.c net: mhi: Remove redundant initialization owner in mhi_net_driver 2023-08-10 17:29:42 -07:00
mii.c net: mii: add C73 link mode and base page helpers 2023-10-30 17:16:55 +08:00
net_failover.c net/net_failover: fix txq exceeding warning 2023-03-27 08:08:57 +01:00
netconsole.c net: netconsole: Disable target before netpoll cleanup 2024-08-03 08:54:13 +02:00
nlmon.c net: don't include ethtool.h from netdevice.h 2020-11-23 17:27:04 -08:00
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 driver core: class: remove struct class_interface * from callbacks 2023-04-03 21:42:52 +02:00
sb1000.c net: dev: Makes sure netif_rx() can be invoked in any context. 2022-02-14 13:38:35 +00:00
Space.c net: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:07 -07:00
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 net: add netdev_lockdep_set_classes() to virtual drivers 2024-04-13 13:07:30 +02:00
virtio_net.c virtio_net: Fix napi_skb_cache_put warning 2024-09-08 07:54:49 +02:00
vrf.c net: Move {l,t,d}stats allocation to core and convert veth & vrf 2023-12-03 07:33:04 +01:00
vsockmon.c net: don't include ethtool.h from netdevice.h 2020-11-23 17:27:04 -08:00
xen-netfront.c xen-netfront: Add missing skb_mark_for_recycle 2024-04-10 16:35:49 +02:00