Skip to content
This repository has been archived by the owner on Nov 7, 2021. It is now read-only.

Commit

Permalink
net: dsa: b53: fix an off by one in checking "vlan->vid"
Browse files Browse the repository at this point in the history
commit 8e4052c32d6b4b39c1e13c652c7e33748d447409 upstream.

The > comparison should be >= to prevent accessing one element beyond
the end of the dev->vlans[] array in the caller function, b53_vlan_add().
The "dev->vlans" array is allocated in the b53_switch_init() function
and it has "dev->num_vlans" elements.

Fixes: a2482d2 ("net: dsa: b53: Plug in VLAN support")
Signed-off-by: Dan Carpenter <[email protected]>
Acked-by: Florian Fainelli <[email protected]>
Link: https://lore.kernel.org/r/YAbxI97Dl/pmBy5V@mwanda
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Dan Carpenter authored and gregkh committed Jan 30, 2021
1 parent ed4b430 commit 24c1a3d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/dsa/b53/b53_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ static int b53_vlan_prepare(struct dsa_switch *ds, int port,
if ((is5325(dev) || is5365(dev)) && vlan->vid_begin == 0)
return -EOPNOTSUPP;

if (vlan->vid_end > dev->num_vlans)
if (vlan->vid_end >= dev->num_vlans)
return -ERANGE;

b53_enable_vlan(dev, true);
Expand Down

0 comments on commit 24c1a3d

Please sign in to comment.