net: dsa: b53: fix an off by one in checking "vlan->vid"
Subsystems (5)
PATCH 1/1 net: dsa: b53: fix an off by one in checking "vlan->vid"
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.
--- drivers/net/dsa/b53/b53_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/b53/b53_common.c +1 -1
@@ -1404,7 +1404,7 @@ int b53_vlan_prepare(struct dsa_switch *ds, int port, !(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED))return -EINVAL ; -if (vlan->vid_end > dev->num_vlans) +if (vlan->vid_end >= dev->num_vlans)return -ERANGE ;b53_enable_vlan (dev, true, ds->vlan_filtering);
Signature · 1 line
2.29.2
Quoted 7 lines · Dan Carpenter
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 theb53_switch_init()function and it has "dev->num_vlans" elements.Fixes a2482d2ce349 ("net: dsa: b53: Plug in VLAN support")Signed-off-by Dan Carpenter <[email protected]>
Signature · 1 line
Florian
Quoted 10 lines · On Tue, 19 Jan 2021 09:14:03 -0800 Florian Fainelli wrote:
Quoted 7 lines · Dan Carpenter
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 theb53_switch_init()function and it has "dev->num_vlans" elements.Fixes a2482d2ce349 ("net: dsa: b53: Plug in VLAN support")Signed-off-by Dan Carpenter <[email protected]>Acked-by Florian Fainelli <[email protected]>
Applied, thanks!