aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2016-06-04 15:16:56 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-04 17:29:53 -0400
commit149cafd790573294752787f5ce1dc0f99e4088d3 (patch)
treea7242119cc023908a8544027942a0cbfbe502dbc /net/dsa
parent6e8e862ded41bd966b088960ad6f4dc7a1a3ce36 (diff)
net: dsa: tag_{e}dsa.c: Remove dependency on platform data
The platform data nr_chips is used when validating a received packet, to ensure it comes from a know switch chip. The number of possible switches is limited to DSA_MAX_SWITCHES, so use this as the first validation step. The new binding allows holes in the dst->ds[] array, so also ensure ensure there is a valid dsa_switch for this packet. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/tag_dsa.c6
-rw-r--r--net/dsa/tag_edsa.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c
index aa780e4ac0bd..f9832f097681 100644
--- a/net/dsa/tag_dsa.c
+++ b/net/dsa/tag_dsa.c
@@ -107,9 +107,13 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev,
107 * Check that the source device exists and that the source 107 * Check that the source device exists and that the source
108 * port is a registered DSA port. 108 * port is a registered DSA port.
109 */ 109 */
110 if (source_device >= dst->pd->nr_chips) 110 if (source_device >= DSA_MAX_SWITCHES)
111 goto out_drop; 111 goto out_drop;
112
112 ds = dst->ds[source_device]; 113 ds = dst->ds[source_device];
114 if (!ds)
115 goto out_drop;
116
113 if (source_port >= DSA_MAX_PORTS || ds->ports[source_port] == NULL) 117 if (source_port >= DSA_MAX_PORTS || ds->ports[source_port] == NULL)
114 goto out_drop; 118 goto out_drop;
115 119
diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c
index 2288c8098c42..3890aac8190f 100644
--- a/net/dsa/tag_edsa.c
+++ b/net/dsa/tag_edsa.c
@@ -120,9 +120,13 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev,
120 * Check that the source device exists and that the source 120 * Check that the source device exists and that the source
121 * port is a registered DSA port. 121 * port is a registered DSA port.
122 */ 122 */
123 if (source_device >= dst->pd->nr_chips) 123 if (source_device >= DSA_MAX_SWITCHES)
124 goto out_drop; 124 goto out_drop;
125
125 ds = dst->ds[source_device]; 126 ds = dst->ds[source_device];
127 if (!ds)
128 goto out_drop;
129
126 if (source_port >= DSA_MAX_PORTS || ds->ports[source_port] == NULL) 130 if (source_port >= DSA_MAX_PORTS || ds->ports[source_port] == NULL)
127 goto out_drop; 131 goto out_drop;
128 132