net: emaclite: Fix position of lp->mii_bus assignment
authorRadhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Wed, 13 Jun 2018 06:35:16 +0000 (12:05 +0530)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Jun 2018 00:08:03 +0000 (17:08 -0700)
To ensure MDIO bus is not double freed in remove() path
assign lp->mii_bus after MDIO bus registration.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/xilinx/xilinx_emaclite.c

index 69e31ceccfae4d90a56f6e49312112ec372d1d48..37989ce543ba5ddc890508367eed7f943820e01e 100644 (file)
@@ -863,14 +863,14 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
        bus->write = xemaclite_mdio_write;
        bus->parent = dev;
 
-       lp->mii_bus = bus;
-
        rc = of_mdiobus_register(bus, np);
        if (rc) {
                dev_err(dev, "Failed to register mdio bus.\n");
                goto err_register;
        }
 
+       lp->mii_bus = bus;
+
        return 0;
 
 err_register: