aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa/slave.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2016-03-11 18:01:37 -0500
committerDavid S. Miller <davem@davemloft.net>2016-03-14 15:43:10 -0400
commitb71be352f76ac3c0559feec2fd960ab9c31404c9 (patch)
tree4f49a80ac245645735c74989efe5d233a8697968 /net/dsa/slave.c
parentca3dfa51e67cd41f6514b84a88bc101e8b1a139a (diff)
dsa: slave: Don't reference NULL pointer during phy_disconnect
When the phy is disconnected, the parent pointer to the netdev it was attached to is set to NULL. The code then tries to suspend the phy, but dsa_slave_fixed_link_update needs the parent pointer to determine which switch the phy is connected to. So it dereferenced a NULL pointer. Check for this condition. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/slave.c')
-rw-r--r--net/dsa/slave.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 27bf03d11670..49056d90b179 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -896,11 +896,15 @@ static void dsa_slave_adjust_link(struct net_device *dev)
896static int dsa_slave_fixed_link_update(struct net_device *dev, 896static int dsa_slave_fixed_link_update(struct net_device *dev,
897 struct fixed_phy_status *status) 897 struct fixed_phy_status *status)
898{ 898{
899 struct dsa_slave_priv *p = netdev_priv(dev); 899 struct dsa_slave_priv *p;
900 struct dsa_switch *ds = p->parent; 900 struct dsa_switch *ds;
901 901
902 if (ds->drv->fixed_link_update) 902 if (dev) {
903 ds->drv->fixed_link_update(ds, p->port, status); 903 p = netdev_priv(dev);
904 ds = p->parent;
905 if (ds->drv->fixed_link_update)
906 ds->drv->fixed_link_update(ds, p->port, status);
907 }
904 908
905 return 0; 909 return 0;
906} 910}