Commit 6f2c9bd8 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by David S. Miller

net: gianfar: fix reference counting for phy_node

The line before the changed if condition is:

	priv->phy_node = of_parse_phandle(np, "phy-handle", 0);

. If this call succeeds priv->phy_node must not be overwritten in the if
block; otherwise the reference to the node returned by of_parse_phandle
is lost. So add a check that the if block isn't executed in this case.

Furthermore in the fixed phy case no reference is aquired for phy_node
resulting in an of_node_put without holding a reference. To fix that,
get a reference on the MAC dt node.

Fixes: be403645 ("gianfar: use the new fixed PHY helpers")
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c891c24c
...@@ -892,12 +892,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) ...@@ -892,12 +892,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
/* In the case of a fixed PHY, the DT node associated /* In the case of a fixed PHY, the DT node associated
* to the PHY is the Ethernet MAC DT node. * to the PHY is the Ethernet MAC DT node.
*/ */
if (of_phy_is_fixed_link(np)) { if (!priv->phy_node && of_phy_is_fixed_link(np)) {
err = of_phy_register_fixed_link(np); err = of_phy_register_fixed_link(np);
if (err) if (err)
goto err_grp_init; goto err_grp_init;
priv->phy_node = np; priv->phy_node = of_node_get(np);
} }
/* Find the TBI PHY. If it's not there, we don't support SGMII */ /* Find the TBI PHY. If it's not there, we don't support SGMII */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment