net/mlx5e: Fix overrun reported by coverity
authorJianbo Liu <jianbol@nvidia.com>
Tue, 14 Nov 2023 01:25:21 +0000 (01:25 +0000)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 14 Dec 2023 01:22:17 +0000 (17:22 -0800)
commitda75fa542873e5f7d7f615566c0b00042d8a0437
treecab8fa7fd39011d97bbb9bb2bbd40e3f538d1a3c
parente75efc6466ae289e599fb12a5a86545dff245c65
net/mlx5e: Fix overrun reported by coverity

Coverity Scan reports the following issue. But it's impossible that
mlx5_get_dev_index returns 7 for PF, even if the index is calculated
from PCI FUNC ID. So add the checking to make coverity slience.

CID 610894 (#2 of 2): Out-of-bounds write (OVERRUN)
Overrunning array esw->fdb_table.offloads.peer_miss_rules of 4 8-byte
elements at element index 7 (byte offset 63) using index
mlx5_get_dev_index(peer_dev) (which evaluates to 7).

Fixes: 9bee385a6e39 ("net/mlx5: E-switch, refactor FDB miss rule add/remove")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c