Skip to content

Commit

Permalink
net: dsa: don't call switchdev_bridge_port_unoffload for unoffloaded …
Browse files Browse the repository at this point in the history
…bridge ports

For ports that have a NULL dp->bridge_dev, dsa_port_to_bridge_port()
also returns NULL as expected.

Issue #1 is that we are performing a NULL pointer dereference on brport_dev.

Issue #2 is that these are ports on which switchdev_bridge_port_offload
has not been called, so we should not call switchdev_bridge_port_unoffload
on them either.

Both issues are addressed by checking against a NULL brport_dev in
dsa_port_pre_bridge_leave and exiting early.

Fixes: 2f5dc00 ("net: bridge: switchdev: let drivers inform which bridge ports are offloaded")
Signed-off-by: Vladimir Oltean <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
vladimiroltean authored and davem330 committed Aug 24, 2021
1 parent 0384dd9 commit 09dba21
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/dsa/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ void dsa_port_pre_bridge_leave(struct dsa_port *dp, struct net_device *br)
{
struct net_device *brport_dev = dsa_port_to_bridge_port(dp);

/* Don't try to unoffload something that is not offloaded */
if (!brport_dev)
return;

switchdev_bridge_port_unoffload(brport_dev, dp,
&dsa_slave_switchdev_notifier,
&dsa_slave_switchdev_blocking_notifier);
Expand Down

0 comments on commit 09dba21

Please sign in to comment.