diff mbox series

[net] net: sparx5: Fix add vlan when invalid operation

Message ID 20220225101516.mhafzkt3mlgmdafc@wse-c0155 (mailing list archive)
State Accepted
Commit b3a34dc362c03215031b268fcc0b988e69490231
Delegated to: Netdev Maintainers
Headers show
Series [net] net: sparx5: Fix add vlan when invalid operation | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: linux-arm-kernel@lists.infradead.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Casper Andersson Feb. 25, 2022, 10:15 a.m. UTC
Check if operation is valid before changing any
settings in hardware. Otherwise it results in
changes being made despite it not being a valid
operation.

Fixes: 78eab33bb68b ("net: sparx5: add vlan support")

Signed-off-by: Casper Andersson <casper.casan@gmail.com>
---
Maybe not obvious from the code changes, but the code is moved down
a couple lines to after check for if it tries to add a second untagged
VLAN to a port. Multiple untagged VLANs on a port is not allowed, but
the changes were made to the hardware anyways.

 .../ethernet/microchip/sparx5/sparx5_vlan.c   | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 25, 2022, 1 p.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 25 Feb 2022 11:15:16 +0100 you wrote:
> Check if operation is valid before changing any
> settings in hardware. Otherwise it results in
> changes being made despite it not being a valid
> operation.
> 
> Fixes: 78eab33bb68b ("net: sparx5: add vlan support")
> 
> [...]

Here is the summary with links:
  - [net] net: sparx5: Fix add vlan when invalid operation
    https://git.kernel.org/netdev/net/c/b3a34dc362c0

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c b/drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c
index 4ce490a25f33..8e56ffa1c4f7 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c
@@ -58,16 +58,6 @@  int sparx5_vlan_vid_add(struct sparx5_port *port, u16 vid, bool pvid,
 	struct sparx5 *sparx5 = port->sparx5;
 	int ret;
 
-	/* Make the port a member of the VLAN */
-	set_bit(port->portno, sparx5->vlan_mask[vid]);
-	ret = sparx5_vlant_set_mask(sparx5, vid);
-	if (ret)
-		return ret;
-
-	/* Default ingress vlan classification */
-	if (pvid)
-		port->pvid = vid;
-
 	/* Untagged egress vlan classification */
 	if (untagged && port->vid != vid) {
 		if (port->vid) {
@@ -79,6 +69,16 @@  int sparx5_vlan_vid_add(struct sparx5_port *port, u16 vid, bool pvid,
 		port->vid = vid;
 	}
 
+	/* Make the port a member of the VLAN */
+	set_bit(port->portno, sparx5->vlan_mask[vid]);
+	ret = sparx5_vlant_set_mask(sparx5, vid);
+	if (ret)
+		return ret;
+
+	/* Default ingress vlan classification */
+	if (pvid)
+		port->pvid = vid;
+
 	sparx5_vlan_port_apply(sparx5, port);
 
 	return 0;