mlxsw: Verify the accessed index doesn't exceed the array length
authorDanielle Ratson <danieller@nvidia.com>
Mon, 17 May 2021 17:03:57 +0000 (20:03 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 May 2021 22:15:46 +0000 (15:15 -0700)
commit837ec05cfea08284c575e8e834777b107da5ff9d
treedd4cf1ed79684b1aa8a76f43e9dcca92a56dc08e
parentece5df874d3a80fcade92ca3b3877bd78dbb6116
mlxsw: Verify the accessed index doesn't exceed the array length

There are few cases in which an array index queried from a fw register,
is accessed without any validation that it doesn't exceed the array
length.

Add a proper length validation, so accessing memory past the end of an
array will be forbidden.

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/minimal.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c