Re: [PATCH v2 net] net: phy: clear phydev->devlink when the link is deleted
From: Russell King (Oracle)
Date: Wed Jun 04 2025 - 04:10:16 EST
On Wed, Jun 04, 2025 at 06:00:54AM +0000, Wei Fang wrote:
> I think this issue is also introduced by the commit bc66fa87d4fd
> ("net: phy: Add link between phy dev and mac dev"). I suggested
> to change the DL_FLAG_STATELESS flag to
> DL_FLAG_AUTOREMOVE_SUPPLIER to solve this issue, so that
> the consumer (MAC controller) driver will be automatically removed
> when the link is removed. The changes are as follows.
I suspect this still has problems. This is fine if the PHY device is
going away and as you say device_del() is called.
However, you need to consider the case where a MAC driver attaches the
PHY during .ndo_open and releases it during .ndo_release. These will
happen multiple times.
Each time the MAC driver attaches to the PHY via .ndo_open, we will
call device_link_add(), but the device link will not be removed when
.ndo_release is called.
Either device_link_add() will fail, or we will eat memory each time
the device is closed and re-opened.
If that is correct, then we're trading one problem for another.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!