Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6f7d9c0 authored by Sean Wang's avatar Sean Wang Committed by David S. Miller
Browse files

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: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3e60b748
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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;
}