net/mlx5e: Check the number of elements before walk TC rhashtable
authorJianbo Liu <jianbol@nvidia.com>
Thu, 12 Oct 2023 02:00:44 +0000 (02:00 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Dec 2023 16:01:44 +0000 (17:01 +0100)
commit4a95f412b7ee000b279df4842ad227a6eadec89c
tree85d3c045b2ec318e41fe4cb9e393685b05295117
parent594a306461de8617a4b497b88a0c7670c4d93f2e
net/mlx5e: Check the number of elements before walk TC rhashtable

[ Upstream commit 4e25b661f484df54b6751b65f9ea2434a3b67539 ]

After IPSec TX tables are destroyed, the flow rules in TC rhashtable,
which have the destination to IPSec, are restored to the original
one, the uplink.

However, when the device is in switchdev mode and unload driver with
IPSec rules configured, TC rhashtable cleanup is done before IPSec
cleanup, which means tc_ht->tbl is already freed when walking TC
rhashtable, in order to restore the destination. So add the checking
before walking to avoid unexpected behavior.

Fixes: d1569537a837 ("net/mlx5e: Modify and restore TC rules for IPSec TX rules")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c