Skip to content

Commit

Permalink
net: dsa: Discard frames from unused ports
Browse files Browse the repository at this point in the history
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: 91da11f ("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>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed Apr 8, 2018
1 parent 6780db2 commit fc5f337
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion net/dsa/dsa_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_switch_tree *dst = cpu_dp->dst;
struct dsa_switch *ds;
struct dsa_port *slave_port;

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

return ds->ports[port].slave;
slave_port = &ds->ports[port];

if (unlikely(slave_port->type != DSA_PORT_TYPE_USER))
return NULL;

return slave_port->slave;
}

/* port.c */
Expand Down

0 comments on commit fc5f337

Please sign in to comment.