Skip to content

Commit

Permalink
net: dsa: Fix off by one in dsa_loop_port_vlan_add()
Browse files Browse the repository at this point in the history
The > comparison is intended to be >= to prevent reading beyond the
end of the ps->vlans[] array.  It doesn't affect run time though because
the ps->vlans[] array has VLAN_N_VID (4096) elements and the vlan->vid
cannot be > 4094 because it is checked earlier.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/YAbyb5kBJQlpYCs2@mwanda
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Dan Carpenter authored and Jakub Kicinski committed Jan 21, 2021
1 parent 0fe2f27 commit 646188c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/dsa/dsa_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static int dsa_loop_port_vlan_add(struct dsa_switch *ds, int port,
struct mii_bus *bus = ps->bus;
struct dsa_loop_vlan *vl;

if (vlan->vid > ARRAY_SIZE(ps->vlans))
if (vlan->vid >= ARRAY_SIZE(ps->vlans))
return -ERANGE;

/* Just do a sleeping operation to make lockdep checks effective */
Expand Down

0 comments on commit 646188c

Please sign in to comment.