net: dsa: b53: fix an off by one in checking "vlan->vid"
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 19 Jan 2021 14:48:03 +0000 (17:48 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jan 2021 10:47:55 +0000 (11:47 +0100)
commitccc248b6444aa4867c85ba1de9d0c907855e414c
tree46b5e89de3a13ccb64e3b4f3010ea2b2c92f014f
parentff64094dc71823938acb595cab27a4b07d6a6cd1
net: dsa: b53: fix an off by one in checking "vlan->vid"

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: a2482d2ce349 ("net: dsa: b53: Plug in VLAN support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/YAbxI97Dl/pmBy5V@mwanda
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/dsa/b53/b53_common.c