net: stmmac: remove redundant racy tear-down in stmmac_dvr_remove()
Subsystems (4)
PATCH 1/1 net: stmmac: remove redundant racy tear-down in stmmac_dvr_remove()
While the network device is registered, it is published to userspace, and thus userspace can change its state. This means calling functions such as stmmac_stop_all_dma() and stmmac_mac_set() are racy.
Moreover, unregister_netdev() will unpublish the network device, and then if appropriate call the .ndo_stop() method, which is stmmac_release(). This will first call phylink_stop() which will synchronously take the link down, resulting in stmmac_mac_link_down() and stmmac_mac_set(, false) being called.
stmmac_release() will also call stmmac_stop_all_dma().
Consequently, neither of these two functions need to called prior to unregister_netdev() as that will safely call paths that will result in this work being done if necessary.
Remove these redundant racy calls.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -2
@@ -7768,8 +7768,6 @@ void stmmac_dvr_remove(struct device *dev)pm_runtime_get_sync (dev); -stmmac_stop_all_dma (priv); -stmmac_mac_set (priv, priv->ioaddr, false);unregister_netdev (ndev);#ifdef CONFIG_DEBUG_FS
Signature · 1 line
2.30.2
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 5 lines · On Fri, 14 Mar 2025 18:02:39 +0000 you wrote:
While the network device is registered, it is published to userspace, and thus userspace can change its state. This means calling functions such as
stmmac_stop_all_dma()andstmmac_mac_set()are racy.
Quoted 7 lines
Moreover,
unregister_netdev()will unpublish the network device, and then if appropriate call the .ndo_stop() method, which isstmmac_release(). This will first callphylink_stop()which will synchronously take the link down, resulting instmmac_mac_link_down()andstmmac_mac_set(, false)being called.[...]
Here is the summary with links:
- [net-next] net: stmmac: remove redundant racy tear-down in stmmac_dvr_remove()
https://git.kernel.org/netdev/net-next/c/180fa8d0a2cb
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html