]>
Commit | Line | Data |
---|---|---|
1d0a9062 GKH |
1 | From foo@baz Tue Apr 10 23:19:36 CEST 2018 |
2 | From: Andrew Lunn <andrew@lunn.ch> | |
3 | Date: Sat, 7 Apr 2018 20:37:40 +0200 | |
4 | Subject: net: dsa: Discard frames from unused ports | |
5 | ||
6 | From: Andrew Lunn <andrew@lunn.ch> | |
7 | ||
8 | ||
9 | [ Upstream commit fc5f33768cca7144f8d793205b229d46740d183b ] | |
10 | ||
11 | The Marvell switches under some conditions will pass a frame to the | |
12 | host with the port being the CPU port. Such frames are invalid, and | |
13 | should be dropped. Not dropping them can result in a crash when | |
14 | incrementing the receive statistics for an invalid port. | |
15 | ||
16 | Reported-by: Chris Healy <cphealy@gmail.com> | |
17 | Fixes: 91da11f870f0 ("net: Distributed Switch Architecture protocol support") | |
18 | Signed-off-by: Andrew Lunn <andrew@lunn.ch> | |
19 | Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> | |
20 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
21 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
22 | --- | |
23 | net/dsa/dsa_priv.h | 8 +++++++- | |
24 | 1 file changed, 7 insertions(+), 1 deletion(-) | |
25 | ||
26 | --- a/net/dsa/dsa_priv.h | |
27 | +++ b/net/dsa/dsa_priv.h | |
28 | @@ -117,6 +117,7 @@ static inline struct net_device *dsa_mas | |
29 | struct dsa_port *cpu_dp = dev->dsa_ptr; | |
30 | struct dsa_switch_tree *dst = cpu_dp->dst; | |
31 | struct dsa_switch *ds; | |
32 | + struct dsa_port *slave_port; | |
33 | ||
34 | if (device < 0 || device >= DSA_MAX_SWITCHES) | |
35 | return NULL; | |
36 | @@ -128,7 +129,12 @@ static inline struct net_device *dsa_mas | |
37 | if (port < 0 || port >= ds->num_ports) | |
38 | return NULL; | |
39 | ||
40 | - return ds->ports[port].slave; | |
41 | + slave_port = &ds->ports[port]; | |
42 | + | |
43 | + if (unlikely(slave_port->type != DSA_PORT_TYPE_USER)) | |
44 | + return NULL; | |
45 | + | |
46 | + return slave_port->slave; | |
47 | } | |
48 | ||
49 | /* port.c */ |