The join rollback broadcasts DSA_NOTIFIER_BRIDGE_LEAVE before the bridge port is destroyed, so drivers' port_bridge_leave() see the port still bridged, while anywhere else (join / leave) promise the effective configuration is applied before that method is called. Mirror the normal leave path and destroy first. Signed-off-by: David Yang --- net/dsa/port.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index 54c970984095..66dba29fade8 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -509,8 +509,10 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, info.bridge = *dp->bridge; err = dsa_broadcast(DSA_NOTIFIER_BRIDGE_JOIN, &info); - if (err) - goto out_rollback; + if (err) { + dsa_port_bridge_destroy(dp, br); + return err; + } /* Drivers which support bridge TX forwarding should set this */ dp->bridge->tx_fwd_offload = info.tx_fwd_offload; @@ -534,9 +536,11 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, &dsa_user_switchdev_blocking_notifier); dsa_flush_workqueue(); out_rollback_unbridge: - dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info); -out_rollback: + /* Align with dsa_port_bridge_leave(), so that drivers' implementations + * always see the port unbridged. + */ dsa_port_bridge_destroy(dp, br); + dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info); return err; } -- 2.53.0