Skip to content

Commit

Permalink
net: dsa: properly check for the bridge_leave methods in dsa_switch_b…
Browse files Browse the repository at this point in the history
…ridge_leave()

This was not caught because there is no switch driver which implements
the .port_bridge_join but not .port_bridge_leave method, but it should
nonetheless be fixed, as in certain conditions (driver development) it
might lead to NULL pointer dereference.

Fixes: f66a6a6 ("net: dsa: permit cross-chip bridging between all trees in the system")
Signed-off-by: Vladimir Oltean <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
vladimiroltean authored and davem330 committed Jul 13, 2021
1 parent 28efd20 commit bcb9928
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/dsa/switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds,
int err, port;

if (dst->index == info->tree_index && ds->index == info->sw_index &&
ds->ops->port_bridge_join)
ds->ops->port_bridge_leave)
ds->ops->port_bridge_leave(ds, info->port, info->br);

if ((dst->index != info->tree_index || ds->index != info->sw_index) &&
ds->ops->crosschip_bridge_join)
ds->ops->crosschip_bridge_leave)
ds->ops->crosschip_bridge_leave(ds, info->tree_index,
info->sw_index, info->port,
info->br);
Expand Down

0 comments on commit bcb9928

Please sign in to comment.