mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-11 15:49:56 +00:00
net: dsa: slave: fix of-node leak and phy priority
Make sure to drop the reference taken by of_parse_phandle() before returning from dsa_slave_phy_setup(). Note that this also modifies the PHY priority so that any fixed-link node is only parsed when no phy-handle is given, which is in accordance with the common scheme for this. Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a510887824
commit
0d8f3c6715
@ -1125,7 +1125,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
|
|||||||
p->phy_interface = mode;
|
p->phy_interface = mode;
|
||||||
|
|
||||||
phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
|
phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
|
||||||
if (of_phy_is_fixed_link(port_dn)) {
|
if (!phy_dn && of_phy_is_fixed_link(port_dn)) {
|
||||||
/* In the case of a fixed PHY, the DT node associated
|
/* In the case of a fixed PHY, the DT node associated
|
||||||
* to the fixed PHY is the Port DT node
|
* to the fixed PHY is the Port DT node
|
||||||
*/
|
*/
|
||||||
@ -1135,7 +1135,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
phy_is_fixed = true;
|
phy_is_fixed = true;
|
||||||
phy_dn = port_dn;
|
phy_dn = of_node_get(port_dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ds->ops->get_phy_flags)
|
if (ds->ops->get_phy_flags)
|
||||||
@ -1154,6 +1154,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
|
|||||||
ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
|
ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
|
netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
|
||||||
|
of_node_put(phy_dn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1162,6 +1163,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
|
|||||||
phy_flags,
|
phy_flags,
|
||||||
p->phy_interface);
|
p->phy_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
of_node_put(phy_dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->phy && phy_is_fixed)
|
if (p->phy && phy_is_fixed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user