mirror of
https://xff.cz/git/u-boot/
synced 2025-10-27 16:43:32 +01:00
driver: net: fsl-mc: fix error handing in init_phy
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>
This commit is contained in:
committed by
Joe Hershberger
parent
d75e81d9e0
commit
f259c43d89
@@ -23,6 +23,7 @@ static int init_phy(struct eth_device *dev)
|
|||||||
struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;
|
struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;
|
||||||
struct phy_device *phydev = NULL;
|
struct phy_device *phydev = NULL;
|
||||||
struct mii_dev *bus;
|
struct mii_dev *bus;
|
||||||
|
int ret;
|
||||||
|
|
||||||
bus = wriop_get_mdio(priv->dpmac_id);
|
bus = wriop_get_mdio(priv->dpmac_id);
|
||||||
if (bus == NULL)
|
if (bus == NULL)
|
||||||
@@ -37,7 +38,14 @@ static int init_phy(struct eth_device *dev)
|
|||||||
|
|
||||||
wriop_set_phy_dev(priv->dpmac_id, phydev);
|
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
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user