net/mlx5: DR, fix a potential use-after-free bug
authorWentao_Liang <Wentao_Liang_g@163.com>
Thu, 19 Aug 2021 14:30:05 +0000 (22:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:40:34 +0000 (13:40 +0200)
commit9c5c65ecbd87c3d7ab5bb44187038c4865cb7dd0
tree0797d493346c4d326059b1d0d43beccf31f182a3
parent4bbf0a9d90e8e56b5dfa46f3e5feb96091f16300
net/mlx5: DR, fix a potential use-after-free bug

[ Upstream commit 6cc64770fb386b10a64a1fe09328396de7bb5262 ]

In line 849 (#1), "mlx5dr_htbl_put(cur_htbl);" drops the reference to
cur_htbl and may cause cur_htbl to be freed.

However, cur_htbl is subsequently used in the next line, which may result
in an use-after-free bug.

Fix this by calling mlx5dr_err() before the cur_htbl is put.

Signed-off-by: Wentao_Liang <Wentao_Liang_g@163.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c