net: axienet: fix teardown order of MDIO bus
authorRobert Hancock <hancock@sedsystems.ca>
Thu, 6 Jun 2019 22:28:10 +0000 (16:28 -0600)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Jun 2019 23:24:29 +0000 (16:24 -0700)
Since the MDIO is is brought up before the netdev is registered, it
should be torn down after the netdev is removed. Otherwise, PHY accesses
can potentially access freed MDIO bus references and cause a crash.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/xilinx/xilinx_axienet_main.c

index 42b343cb3e2b853a2b3e6bcbe99e7ff453443a2a..5cb39deca8d2cc18559f0f661a52f09bc2f27285 100644 (file)
@@ -1651,8 +1651,8 @@ static int axienet_remove(struct platform_device *pdev)
        struct net_device *ndev = platform_get_drvdata(pdev);
        struct axienet_local *lp = netdev_priv(ndev);
 
-       axienet_mdio_teardown(lp);
        unregister_netdev(ndev);
+       axienet_mdio_teardown(lp);
 
        if (lp->clk)
                clk_disable_unprepare(lp->clk);