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:
committed by
David S. Miller
parent
bb66be1c54
commit
d79d210736
@@ -165,6 +165,11 @@ static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
|
||||
return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port);
|
||||
}
|
||||
|
||||
static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p)
|
||||
{
|
||||
return ds->phys_port_mask & (1 << p) && ds->ports[p];
|
||||
}
|
||||
|
||||
static inline u8 dsa_upstream_port(struct dsa_switch *ds)
|
||||
{
|
||||
struct dsa_switch_tree *dst = ds->dst;
|
||||
|
||||
Reference in New Issue
Block a user