[PATCH net-next v6 0/2] net: phy: fix a second attach of an attached PHY and the module put on detach
From: Aleksei Sviridkin
Date: Tue Oct 13 2026 - 14:57:03 EST
Two phylib fixes found on a Keenetic KN-1012 (MT7981) while chasing a
PHY driver unbind race. A second attach of an attached PHY tears down
the first consumer, and a detach after a driver unbind leaks the module
reference.
1: refuse a second attach before the driver module is taken or the
generic driver bound.
2: put the module the attach pinned, not whatever driver is bound at
detach.
Patch 1 goes first: with patch 2 alone, the second attach error path
leaves the first consumer's module reference pinned.
Changes in v6 (since v5):
https://lore.kernel.org/netdev/20261009180551.1234107-1-f@xxxxxx/
- Dropped patches 3 and 4 (the bind_lock and the unbind wait), as
Andrew suggested: unbinding a PHY driver is a development tool and
not worth that complexity.
- Dropped the Fixes tags, the series targets net-next.
- Patch 2: added Andrew's Reviewed-by.
Aleksei Sviridkin (2):
net: phy: refuse a second attach before touching the PHY
net: phy: put the driver module the attach took
drivers/net/phy/phy_device.c | 25 +++++++++++++++----------
include/linux/phy.h | 2 ++
2 files changed, 17 insertions(+), 10 deletions(-)
--
2.53.0