Re: [PATCH net v2] net: usb: lan78xx: let unregister_netdev() stop phylink

From: Oleksij Rempel

Date: Tue Nov 03 2026 - 00:32:56 EST


On Sun, Nov 01, 2026 at 12:52:13AM +0800, YuanZhe Liu wrote:
> lan78xx_disconnect() stops phylink before unregistering the net device.
> phylink_start() is only called from lan78xx_open(), so when the device is
> unplugged before the interface has been brought up, the attached PHY is
> still in PHY_READY and phy_stop() reports:
>
> called from state READY
> WARNING: drivers/net/phy/phy.c:1670 at phy_stop+0xad/0x380
>
> The same warning is emitted after an ifup/ifdown cycle, where the PHY is
> already in PHY_HALTED.
>
> unregister_netdev() already closes a running device, which calls
> lan78xx_stop() and phylink_stop() with dev->dev_mutex held and after the
> URBs have been terminated. Unregister first and disconnect the PHY
> afterwards, so the interface is stopped exactly once and only while it is
> running, and the net device can no longer be opened while its phylink
> instance has no PHY attached.
>
> Fixes: e110bc825897 ("net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management")
> Cc: stable@xxxxxxxxxxxxxxx
> Co-developed-by: Bin Yu <byu@xxxxxxxxxxxxx>
> Signed-off-by: Bin Yu <byu@xxxxxxxxxxxxx>
> Co-developed-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
> Signed-off-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
> Signed-off-by: YuanZhe Liu <25031212351@xxxxxxxxxxxxxxxxx>

Tested-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
Reviewed-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>

Thank you!

Best Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |