summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPankaj Bansal <pankaj.bansal@nxp.com>2018-10-10 14:08:31 +0530
committerJoe Hershberger <joe.hershberger@ni.com>2018-10-10 12:43:18 -0500
commitf259c43d893071e3a4f43536735c959dcf320d99 (patch)
tree12746c8a1b45a1b2574f69b2acec1adcbc28e5c4
parentd75e81d9e05575e3f8471e618846565b15b30060 (diff)
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>
-rw-r--r--drivers/net/ldpaa_eth/ldpaa_eth.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 39f81daafd..ef5286c325 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -23,6 +23,7 @@ static int init_phy(struct eth_device *dev)
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)
@@ -37,7 +38,14 @@ static int init_phy(struct eth_device *dev)
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