if an error occurs during init_phy, we should free the phydev structure
which has been allocated by phy_connect.
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;
struct phy_device *phydev = NULL;
struct mii_dev *bus;
+ int ret;
bus = wriop_get_mdio(priv->dpmac_id);
if (bus == NULL)
wriop_set_phy_dev(priv->dpmac_id, phydev);
- return phy_config(phydev);
+ ret = phy_config(phydev);
+
+ if (ret) {
+ free(phydev);
+ wriop_set_phy_dev(priv->dpmac_id, NULL);
+ }
+
+ return ret;
}
#endif