Skip to content

Commit 6f2c9bd

Browse files
Uwe Kleine-Königdavem330
authored andcommitted
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: be40364 ("gianfar: use the new fixed PHY helpers") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c891c24 commit 6f2c9bd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/net/ethernet/freescale/gianfar.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,12 +892,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
892892
/* In the case of a fixed PHY, the DT node associated
893893
* to the PHY is the Ethernet MAC DT node.
894894
*/
895-
if (of_phy_is_fixed_link(np)) {
895+
if (!priv->phy_node && of_phy_is_fixed_link(np)) {
896896
err = of_phy_register_fixed_link(np);
897897
if (err)
898898
goto err_grp_init;
899899

900-
priv->phy_node = np;
900+
priv->phy_node = of_node_get(np);
901901
}
902902

903903
/* Find the TBI PHY. If it's not there, we don't support SGMII */

0 commit comments

Comments
 (0)