Skip to content

Commit fc5f337

Browse files
lunndavem330
authored andcommitted
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 <[email protected]> Fixes: 91da11f ("net: Distributed Switch Architecture protocol support") Signed-off-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6780db2 commit fc5f337

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/dsa/dsa_priv.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
126126
struct dsa_port *cpu_dp = dev->dsa_ptr;
127127
struct dsa_switch_tree *dst = cpu_dp->dst;
128128
struct dsa_switch *ds;
129+
struct dsa_port *slave_port;
129130

130131
if (device < 0 || device >= DSA_MAX_SWITCHES)
131132
return NULL;
@@ -137,7 +138,12 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
137138
if (port < 0 || port >= ds->num_ports)
138139
return NULL;
139140

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;
141147
}
142148

143149
/* port.c */

0 commit comments

Comments
 (0)