Put the mdiodev after xpcs_create() so that the XPCS driver can manage
the lifetime of the mdiodev its using.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
                }
 
                xpcs = xpcs_create(mdiodev, priv->phy_mode[port]);
+               mdio_device_put(mdiodev);
                if (IS_ERR(xpcs)) {
                        rc = PTR_ERR(xpcs);
                        goto out_pcs_free;
                if (!priv->xpcs[port])
                        continue;
 
-               mdio_device_free(priv->xpcs[port]->mdiodev);
                xpcs_destroy(priv->xpcs[port]);
                priv->xpcs[port] = NULL;
        }
                if (!priv->xpcs[port])
                        continue;
 
-               mdio_device_free(priv->xpcs[port]->mdiodev);
                xpcs_destroy(priv->xpcs[port]);
                priv->xpcs[port] = NULL;
        }