* [PATCH net] net: sgi: ioc3-eth: unregister netdev before freeing DMA rings
@ 2026-06-29 8:50 raoxu
2026-06-29 17:18 ` Thomas Bogendoerfer
0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-06-29 8:50 UTC (permalink / raw)
To: tsbogend
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux-mips, netdev,
linux-kernel, raoxu, stable
From: Xu Rao <raoxu@uniontech.com>
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.
Fixes: c7b572747549 ("net: sgi: ioc3-eth: allocate space for desc rings only once")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
drivers/net/ethernet/sgi/ioc3-eth.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
index 261f2d35d579..009f37105eaf 100644
--- a/drivers/net/ethernet/sgi/ioc3-eth.c
+++ b/drivers/net/ethernet/sgi/ioc3-eth.c
@@ -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);
}
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net: sgi: ioc3-eth: unregister netdev before freeing DMA rings
2026-06-29 8:50 [PATCH net] net: sgi: ioc3-eth: unregister netdev before freeing DMA rings raoxu
@ 2026-06-29 17:18 ` Thomas Bogendoerfer
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2026-06-29 17:18 UTC (permalink / raw)
To: raoxu
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux-mips, netdev,
linux-kernel, stable
On Mon, Jun 29, 2026 at 04:50:53PM +0800, raoxu wrote:
> From: Xu Rao <raoxu@uniontech.com>
>
> 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.
>
> Fixes: c7b572747549 ("net: sgi: ioc3-eth: allocate space for desc rings only once")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
> ---
> drivers/net/ethernet/sgi/ioc3-eth.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
> index 261f2d35d579..009f37105eaf 100644
> --- a/drivers/net/ethernet/sgi/ioc3-eth.c
> +++ b/drivers/net/ethernet/sgi/ioc3-eth.c
> @@ -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);
> }
>
> --
> 2.50.1
Reviewed-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-29 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 8:50 [PATCH net] net: sgi: ioc3-eth: unregister netdev before freeing DMA rings raoxu
2026-06-29 17:18 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox