net: macb: NULL out phydev after removing mdio bus
authorNathan Sullivan <[email protected]>
Fri, 7 Oct 2016 15:13:22 +0000 (10:13 -0500)
committerDavid S. Miller <[email protected]>
Sat, 8 Oct 2016 03:55:59 +0000 (23:55 -0400)
To ensure the dev->phydev pointer is not used after becoming invalid in
mdiobus_unregister, set it to NULL. This happens when removing the macb
driver without first taking its interface down, since unregister_netdev
will end up calling macb_close.

Signed-off-by: Xander Huff <[email protected]>
Signed-off-by: Nathan Sullivan <[email protected]>
Signed-off-by: Brad Mouring <[email protected]>
Reviewed-by: Moritz Fischer <[email protected]>
Acked-by: Nicolas Ferre <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/ethernet/cadence/macb.c

index 63144bb413d1696e48c103ee6045d4bc224b952a..b32444a3ed79d311fc4047aa10eabc5f630b66cb 100644 (file)
@@ -3117,6 +3117,7 @@ static int macb_remove(struct platform_device *pdev)
                if (dev->phydev)
                        phy_disconnect(dev->phydev);
                mdiobus_unregister(bp->mii_bus);
+               dev->phydev = NULL;
                mdiobus_free(bp->mii_bus);
 
                /* Shutdown the PHY if there is a GPIO reset */