net: dsa: Introduce dsa_is_port_initialized

To avoid race conditions when using the ds->ports[] array,
we need to check if the accessed port has been initialized.
Introduce and use helper function dsa_is_port_initialized
for that purpose and use it where needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Guenter Roeck 2015-02-24 23:02:02 -08:00 committed by David S. Miller
parent bb66be1c54
commit d79d210736
3 changed files with 8 additions and 6 deletions

View file

@ -222,10 +222,7 @@ static u32 dsa_slave_br_port_mask(struct dsa_switch *ds,
u32 mask = 0;
for (port = 0; port < DSA_MAX_PORTS; port++) {
if (!((1 << port) & ds->phys_port_mask))
continue;
if (!ds->ports[port])
if (!dsa_is_port_initialized(ds, port))
continue;
p = netdev_priv(ds->ports[port]);