net: dsa: return after vlan prepare phase

The current code does not return after successfully preparing the VLAN
addition on every ports member of a it. Fix this.

Fixes: 1ca4aa9cd4cc ("net: dsa: check VLAN capability of every switch")
Signed-off-by: Vivien Didelot <>
Reviewed-by: Andrew Lunn <>
Signed-off-by: David S. Miller <>
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 73746fa..1e2929f 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -182,6 +182,8 @@
 			if (err)
 				return err;
+		return 0;
 	for_each_set_bit(port, members, ds->num_ports)