diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2014-08-07 16:17:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-08-07 19:02:58 -0400 |
commit | 6f2c9bd85eee30fd77e6c65c097769ad0d6d7352 (patch) | |
tree | 5e0ed046be13ca7ad269ff24c9a8b24d70775898 /drivers/net/ethernet | |
parent | c891c24c62b376e508a45eeeb9f37e1b94173126 (diff) |
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: be40364544bd ("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>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 6b0c4775cd0d..fb29d049f4e1 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -892,12 +892,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) | |||
892 | /* In the case of a fixed PHY, the DT node associated | 892 | /* In the case of a fixed PHY, the DT node associated |
893 | * to the PHY is the Ethernet MAC DT node. | 893 | * to the PHY is the Ethernet MAC DT node. |
894 | */ | 894 | */ |
895 | if (of_phy_is_fixed_link(np)) { | 895 | if (!priv->phy_node && of_phy_is_fixed_link(np)) { |
896 | err = of_phy_register_fixed_link(np); | 896 | err = of_phy_register_fixed_link(np); |
897 | if (err) | 897 | if (err) |
898 | goto err_grp_init; | 898 | goto err_grp_init; |
899 | 899 | ||
900 | priv->phy_node = np; | 900 | priv->phy_node = of_node_get(np); |
901 | } | 901 | } |
902 | 902 | ||
903 | /* Find the TBI PHY. If it's not there, we don't support SGMII */ | 903 | /* Find the TBI PHY. If it's not there, we don't support SGMII */ |