Skip to content

Commit

Permalink
net: sparx5: Fix add vlan when invalid operation
Browse files Browse the repository at this point in the history
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: 78eab33 ("net: sparx5: add vlan support")

Signed-off-by: Casper Andersson <casper.casan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Casper Andersson authored and David S. Miller committed Feb 25, 2022
1 parent 767b982 commit b3a34dc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit b3a34dc

Please sign in to comment.