In xgmac_probe, the priv->tx_timeout_work is bound with
xgmac_tx_timeout_work. In xgmac_remove, if there is an
unfinished work, there might be a race condition that
priv->base was written byte after iounmap it.
Fix it by finishing the work before cleanup.
Fixes: 8746f671ef04 ("net: calxedaxgmac: fix race between xgmac_tx_complete and xgmac_tx_err")
Signed-off-by: Zheng Wang <[email protected]>
---
v2:
- fix typo,add Fixes label and stop dev_watchdog so that it will handle no more timeout work suggested by Yunsheng Lin
---
drivers/net/ethernet/calxeda/xgmac.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index f4f87dfa9687..f0880538f6f3 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -1832,6 +1832,10 @@ static int xgmac_remove(struct platform_device *pdev)
free_irq(ndev->irq, ndev);
free_irq(priv->pmt_irq, ndev);
+ netif_carrier_off(ndev);
+ netif_tx_disable(ndev);
+ cancel_work_sync(&priv->tx_timeout_work);
+
unregister_netdev(ndev);
netif_napi_del(&priv->napi);
--
2.25.1
On 2023/3/12 2:04, Zheng Wang wrote:
> In xgmac_probe, the priv->tx_timeout_work is bound with
> xgmac_tx_timeout_work. In xgmac_remove, if there is an
> unfinished work, there might be a race condition that
> priv->base was written byte after iounmap it.
>
> Fix it by finishing the work before cleanup.
>
> Fixes: 8746f671ef04 ("net: calxedaxgmac: fix race between xgmac_tx_complete and xgmac_tx_err")
> Signed-off-by: Zheng Wang <[email protected]>
LGTM.
Reviewed-by: Yunsheng Lin <[email protected]>
> ---
> v2:
> - fix typo,add Fixes label and stop dev_watchdog so that it will handle no more timeout work suggested by Yunsheng Lin
> ---
> drivers/net/ethernet/calxeda/xgmac.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
> index f4f87dfa9687..f0880538f6f3 100644
> --- a/drivers/net/ethernet/calxeda/xgmac.c
> +++ b/drivers/net/ethernet/calxeda/xgmac.c
> @@ -1832,6 +1832,10 @@ static int xgmac_remove(struct platform_device *pdev)
> free_irq(ndev->irq, ndev);
> free_irq(priv->pmt_irq, ndev);
>
> + netif_carrier_off(ndev);
> + netif_tx_disable(ndev);
> + cancel_work_sync(&priv->tx_timeout_work);
> +
> unregister_netdev(ndev);
> netif_napi_del(&priv->napi);
>
>