diff options
author | Andrew Lunn <andrew@lunn.ch> | 2018-04-07 14:37:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-08 10:34:49 -0400 |
commit | fc5f33768cca7144f8d793205b229d46740d183b (patch) | |
tree | d78a133561ac517c10aae6b2baa1d505388fd6df | |
parent | 6780db244d6b1537d139dea0ec8aad10cf9e4adb (diff) |
net: dsa: Discard frames from unused ports
The Marvell switches under some conditions will pass a frame to the
host with the port being the CPU port. Such frames are invalid, and
should be dropped. Not dropping them can result in a crash when
incrementing the receive statistics for an invalid port.
Reported-by: Chris Healy <cphealy@gmail.com>
Fixes: 91da11f870f0 ("net: Distributed Switch Architecture protocol support")
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/dsa/dsa_priv.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 70de7895e5b8..053731473c99 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h | |||
@@ -126,6 +126,7 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev, | |||
126 | struct dsa_port *cpu_dp = dev->dsa_ptr; | 126 | struct dsa_port *cpu_dp = dev->dsa_ptr; |
127 | struct dsa_switch_tree *dst = cpu_dp->dst; | 127 | struct dsa_switch_tree *dst = cpu_dp->dst; |
128 | struct dsa_switch *ds; | 128 | struct dsa_switch *ds; |
129 | struct dsa_port *slave_port; | ||
129 | 130 | ||
130 | if (device < 0 || device >= DSA_MAX_SWITCHES) | 131 | if (device < 0 || device >= DSA_MAX_SWITCHES) |
131 | return NULL; | 132 | return NULL; |
@@ -137,7 +138,12 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev, | |||
137 | if (port < 0 || port >= ds->num_ports) | 138 | if (port < 0 || port >= ds->num_ports) |
138 | return NULL; | 139 | return NULL; |
139 | 140 | ||
140 | return ds->ports[port].slave; | 141 | slave_port = &ds->ports[port]; |
142 | |||
143 | if (unlikely(slave_port->type != DSA_PORT_TYPE_USER)) | ||
144 | return NULL; | ||
145 | |||
146 | return slave_port->slave; | ||
141 | } | 147 | } |
142 | 148 | ||
143 | /* port.c */ | 149 | /* port.c */ |