hip04_remove() frees the netdev before the managed IRQ is released after the remove callback. Since the IRQ handler receives the netdev as its data pointer, a late interrupt can access freed memory. Use a managed netdev allocation. Devres then releases the IRQ, which is registered later, before releasing the netdev. Fixes: a41ea46a9a12 ("net: hisilicon: new hip04 ethernet driver") Cc: stable@vger.kernel.org Signed-off-by: Jiale Yao --- drivers/net/ethernet/hisilicon/hip04_eth.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c index fc2c47dcfaab..4a643dff22ab 100644 --- a/drivers/net/ethernet/hisilicon/hip04_eth.c +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c @@ -905,7 +905,7 @@ static int hip04_mac_probe(struct platform_device *pdev) int irq; int ret; - ndev = alloc_etherdev(sizeof(struct hip04_priv)); + ndev = devm_alloc_etherdev(d, sizeof(struct hip04_priv)); if (!ndev) return -ENOMEM; @@ -1021,7 +1021,6 @@ static int hip04_mac_probe(struct platform_device *pdev) hip04_free_ring(ndev, d); init_fail: of_node_put(priv->phy_node); - free_netdev(ndev); return ret; } @@ -1038,7 +1037,6 @@ static void hip04_remove(struct platform_device *pdev) unregister_netdev(ndev); of_node_put(priv->phy_node); cancel_work_sync(&priv->tx_timeout_task); - free_netdev(ndev); } static const struct of_device_id hip04_mac_match[] = { -- 2.34.1