net: sgi: ioc3-eth: unregister netdev before freeing DMA rings
Subsystems (5)
PATCH 1/1 net: sgi: ioc3-eth: unregister netdev before freeing DMA rings
From: Xu Rao <[email protected]>
ioc3eth_remove() frees the coherent RX and TX descriptor rings before unregistering the netdev. If the interface is running, unregister_netdev() invokes ioc3_close() through ndo_stop.
ioc3_close() stops the device and then calls ioc3_free_rx_bufs() and ioc3_clean_tx_ring(). Both cleanup functions access descriptors in the rings, so the current ordering causes CPU accesses to freed coherent memory. Until ioc3_stop() disables RX and TX DMA, the device may also continue using the freed ring addresses.
Unregister the netdev before releasing the rings. This lets the core close a running interface and quiesce the device while the rings are still valid. Keep the explicit timer deletion because ndo_stop is not called when the interface is already down.
--- drivers/net/ethernet/sgi/ioc3-eth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/sgi/ioc3-eth.c +3 -2
@@ -967,11 +967,12 @@ static void ioc3eth_remove(struct platform_device *pdev)struct net_device *dev =platform_get_drvdata (pdev);struct ioc3_private *ip =netdev_priv (dev); +unregister_netdev (dev); +timer_delete_sync (&ip->ioc3_timer); +dma_free_coherent (ip->dma_dev,RX_RING_SIZE , ip->rxr, ip->rxr_dma);dma_free_coherent (ip->dma_dev,TX_RING_SIZE +SZ_16K -1 , ip->tx_ring, ip->txr_dma); -unregister_netdev (dev); -timer_delete_sync (&ip->ioc3_timer);free_netdev (dev); }
Signature · 1 line
2.50.1
Quoted 45 lines · raoxu
From: Xu Rao <[email protected]>
ioc3eth_remove()frees the coherent RX and TX descriptor rings before unregistering the netdev. If the interface is running,unregister_netdev()invokesioc3_close()throughndo_stop.
ioc3_close()stops the device and then callsioc3_free_rx_bufs()andioc3_clean_tx_ring(). Both cleanup functions access descriptors in the rings, so the current ordering causes CPU accesses to freed coherent memory. Untilioc3_stop()disables RX and TX DMA, the device may also continue using the freed ring addresses.Unregister the netdev before releasing the rings. This lets the core close a running interface and quiesce the device while the rings are still valid. Keep the explicit timer deletion because
ndo_stopis not called when the interface is already down.Fixes c7b572747549 ("net: sgi: ioc3-eth: allocate space for desc rings only once")Signed-off-by Xu Rao <[email protected]>--- drivers/net/ethernet/sgi/ioc3-eth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/ethernet/sgi/ioc3-eth.c +3
-2@@ -967,11 +967,12 @@ static void ioc3eth_remove(struct platform_device *pdev)struct net_device *dev =platform_get_drvdata (pdev);struct ioc3_private *ip =netdev_priv (dev); +unregister_netdev (dev); +timer_delete_sync (&ip->ioc3_timer); +dma_free_coherent (ip->dma_dev,RX_RING_SIZE , ip->rxr, ip->rxr_dma);dma_free_coherent (ip->dma_dev,TX_RING_SIZE +SZ_16K -1 , ip->tx_ring, ip->txr_dma); -unregister_netdev (dev); -timer_delete_sync (&ip->ioc3_timer);free_netdev (dev); }Signature · 1 line
2.50.1
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Mon, 29 Jun 2026 16:50:53 +0800 you wrote:
From: Xu Rao <[email protected]>
ioc3eth_remove()frees the coherent RX and TX descriptor rings before unregistering the netdev. If the interface is running,unregister_netdev()invokesioc3_close()throughndo_stop.
Quoted 7 lines
ioc3_close()stops the device and then callsioc3_free_rx_bufs()andioc3_clean_tx_ring(). Both cleanup functions access descriptors in the rings, so the current ordering causes CPU accesses to freed coherent memory. Untilioc3_stop()disables RX and TX DMA, the device may also continue using the freed ring addresses.[...]
Here is the summary with links:
- [net] net: sgi: ioc3-eth: unregister netdev before freeing DMA rings
https://git.kernel.org/netdev/net-next/c/18a28f3e107e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html