[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1480357509-28074-17-git-send-email-johan@kernel.org>
Date: Mon, 28 Nov 2016 19:25:09 +0100
From: Johan Hovold <johan@...nel.org>
To: "David S. Miller" <davem@...emloft.net>
Cc: Vince Bridgers <vbridger@...nsource.altera.com>,
Florian Fainelli <f.fainelli@...il.com>,
Fugang Duan <fugang.duan@....com>,
Pantelis Antoniou <pantelis.antoniou@...il.com>,
Vitaly Bordug <vbordug@...mvista.com>,
Claudiu Manoil <claudiu.manoil@...escale.com>,
Li Yang <leoli@...escale.com>,
Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
Felix Fietkau <nbd@...nwrt.org>,
John Crispin <blogic@...nwrt.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Sergei Shtylyov <sergei.shtylyov@...entembedded.com>,
Lars Persson <lars.persson@...s.com>,
Mugunthan V N <mugunthanvnm@...com>,
Grygorii Strashko <grygorii.strashko@...com>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...oirfairelinux.com>,
netdev@...r.kernel.org, nios2-dev@...ts.rocketboards.org,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-mediatek@...ts.infradead.org,
linux-renesas-soc@...r.kernel.org, linux-omap@...r.kernel.org,
devicetree@...r.kernel.org, Johan Hovold <johan@...nel.org>
Subject: [PATCH net 16/16] 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: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups")
Signed-off-by: Johan Hovold <johan@...nel.org>
---
net/dsa/slave.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 2a5c20a13fe4..30e2e21d7619 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -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);
if (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;
}
}
@@ -1292,10 +1294,18 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
void dsa_slave_destroy(struct net_device *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);
- if (p->phy)
+ if (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);
free_netdev(slave_dev);
}
--
2.7.3
Powered by blists - more mailing lists