diff options
author | Sean Wang <sean.wang@mediatek.com> | 2016-09-22 16:44:16 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-09-22 08:22:28 -0400 |
commit | f6f7d9c03f5daae04449ad19de5e2f0c20c5eaac (patch) | |
tree | b1a78b9d77b5e806ca9ad88a4fa3c3f5aeb35502 /drivers | |
parent | 3e60b748fd2f50bbdb6a61fdd48222cd492c77e3 (diff) |
net: ethernet: mediatek: get out of potential invalid pointer access
Potential dangerous invalid pointer might be accessed if
the error happens when couple phy_device to net_device so
cleanup the error path.
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index a65801a5e2ee..3d7e0cb601b6 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -296,7 +296,9 @@ static int mtk_phy_connect(struct net_device *dev) regmap_write(eth->ethsys, ETHSYS_SYSCFG0, val); /* couple phydev to net_device */ - mtk_phy_connect_node(eth, mac, np); + if (mtk_phy_connect_node(eth, mac, np)) + goto err_phy; + dev->phydev->autoneg = AUTONEG_ENABLE; dev->phydev->speed = 0; dev->phydev->duplex = 0; @@ -317,7 +319,7 @@ static int mtk_phy_connect(struct net_device *dev) err_phy: of_node_put(np); - dev_err(eth->dev, "invalid phy_mode\n"); + dev_err(eth->dev, "%s: invalid phy\n", __func__); return -EINVAL; } |