提交 881eadab 编写于 作者: J Johan Hovold 提交者: David S. Miller

net: dsa: slave: fix fixed-link phydev leaks

Make sure to deregister and free any fixed-link PHY registered using
of_phy_register_fixed_link() on slave-setup errors and on slave destroy.

Fixes: 0d8bcdd3 ("net: dsa: allow for more complex PHY setups")
Signed-off-by: NJohan Hovold <johan@kernel.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 14cab6f6
...@@ -1177,6 +1177,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, ...@@ -1177,6 +1177,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
ret = dsa_slave_phy_connect(p, slave_dev, p->port); ret = dsa_slave_phy_connect(p, slave_dev, p->port);
if (ret) { if (ret) {
netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret); netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret);
if (phy_is_fixed)
of_phy_deregister_fixed_link(port_dn);
return ret; return ret;
} }
} }
...@@ -1292,10 +1294,18 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, ...@@ -1292,10 +1294,18 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
void dsa_slave_destroy(struct net_device *slave_dev) void dsa_slave_destroy(struct net_device *slave_dev)
{ {
struct dsa_slave_priv *p = netdev_priv(slave_dev); struct dsa_slave_priv *p = netdev_priv(slave_dev);
struct dsa_switch *ds = p->parent;
struct device_node *port_dn;
port_dn = ds->ports[p->port].dn;
netif_carrier_off(slave_dev); netif_carrier_off(slave_dev);
if (p->phy) if (p->phy) {
phy_disconnect(p->phy); phy_disconnect(p->phy);
if (of_phy_is_fixed_link(port_dn))
of_phy_deregister_fixed_link(port_dn);
}
unregister_netdev(slave_dev); unregister_netdev(slave_dev);
free_netdev(slave_dev); free_netdev(slave_dev);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册