Re: [PATCH net v3 03/10] net: au1000: disconnect the PHY before freeing the MDIO bus
From: Florian Fainelli
Date: Fri Nov 20 2026 - 18:58:40 EST
On 11/20/26 02:32, netdev-bot+sashiko@xxxxxxxxxx wrote:
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message of "net: au1000: disconnect the PHY before
freeing the MDIO bus" partly misstates what the patch fixes, and…
--
net: au1000: disconnect the PHY before freeing the MDIO bus
This commit adds phy_disconnect() calls to the au1000_probe() error path
and to au1000_remove(), so that phy_connect() is balanced. It also makes
au1000_reset_mac_unlocked() skip MAC control register accesses when
mac_enabled is clear. It also resets the MAC in au1000_remove() after the
PHY and MDIO bus are torn down.
Balance phy_connect() on probe failure and removal. Otherwise PHY
interrupts, device references and the attachment to the freed netdev
survive teardown.
[Severity: Low]
Can a PHY interrupt actually survive teardown in this driver?
mdiobus_alloc_size() sets every bus->irq[i] to PHY_POLL. au1000_probe()
only writes a real IRQ into mii_bus->irq[] when aup->phy_static_config is
set:
if (aup->phy_static_config)
if (aup->phy_irq && aup->phy_busid == aup->mac_id)
aup->mii_bus->irq[aup->phy_addr] = aup->phy_irq;
In that same case, au1000_mii_probe() returns before it reaches
phy_connect():
if (aup->phy_static_config) {
...
if (aup->phy_addr)
phydev = mdiobus_get_phy(aup->mii_bus, aup->phy_addr);
else
netdev_info(dev, "using PHY-less setup\n");
return 0;
}
That leaves dev->phydev NULL, so the new phy_disconnect() calls are
skipped.
On the dynamic search path, which is the only one that calls
phy_connect(), the PHY's irq is still PHY_POLL. That means no interrupt
is ever requested, and phy_disconnect() never reaches
phy_free_interrupt().
The device and module references taken in phy_attach_direct(), and the
attached_dev pointer to the freed netdev, do look like real leaks. Should
the "PHY interrupts" part be dropped from the message?
PHY teardown can re-enable the MAC for MDIO even if the interface was
never opened. Reset the MAC after PHY and MDIO bus teardown, before
releasing descriptors and register mappings. Skip MAC control accesses
when mac_enabled is clear, since stopping an already clock-gated MAC
hangs MTX-1.
Would it help to say that the new mac_enabled check also fixes an
existing hang when register_netdev() fails in au1000_probe()?
Before this patch, the au1000_reset_mac() call just before
register_netdev() gated the MAC clock and cleared mac_enabled. If
register_netdev() then failed, the err_out path called
mdiobus_unregister(), which does no MDIO access, and then called
au1000_reset_mac() again:
au1000_probe()
au1000_reset_mac(dev); <- clock gated, mac_enabled = 0
register_netdev(dev) fails
goto err_out
mdiobus_unregister()
au1000_reset_mac(dev)
au1000_hard_stop(dev)
readl(&aup->mac->control) <- MAC already clock-gated
According to the commit message, this access hangs MTX-1. The message
describes the PHY teardown case but not this change in the
register_netdev() failure path. Mentioning it would show backporters
which failure modes this patch fixes.
Agreed on both points. I have updated the commit message to remove the PHY-interrupt claim: the path that calls phy_connect() uses polling. The message now describes the leaked device/module references and the stale attached_dev pointer.
I also added the existing register_netdev() failure case. Probe gates the MAC clock before registration, and the error unwind resets it again. The mac_enabled guard prevents that second reset from accessing clock-gated MAC control registers if no intervening MDIO access has re-enabled the MAC.
This is a commit-message-only revision; the code is unchanged. The registration-failure path was verified by source inspection, not fault injection.
pw-bot: cr
--
Florian