提交 0e1fa5cc 编写于 作者: L Leon Romanovsky 提交者: Zheng Zengkai

net/mlx5: Don't use already freed action pointer

stable inclusion
from stable-v5.10.122
commit ea5edd015feb1824002579513e351002bde9226e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5W6OE

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ea5edd015feb1824002579513e351002bde9226e

--------------------------------

[ Upstream commit 80b2bd73 ]

The call to mlx5dr_action_destroy() releases "action" memory. That
pointer is set to miss_action later and generates the following smatch
error:

 drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c:53 set_miss_action()
 warn: 'action' was already freed.

Make sure that the pointer is always valid by setting NULL after destroy.

Fixes: 6a48faee ("net/mlx5: Add direct rule fs_cmd implementation")
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: NSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 b9414209
...@@ -43,11 +43,10 @@ static int set_miss_action(struct mlx5_flow_root_namespace *ns, ...@@ -43,11 +43,10 @@ static int set_miss_action(struct mlx5_flow_root_namespace *ns,
err = mlx5dr_table_set_miss_action(ft->fs_dr_table.dr_table, action); err = mlx5dr_table_set_miss_action(ft->fs_dr_table.dr_table, action);
if (err && action) { if (err && action) {
err = mlx5dr_action_destroy(action); err = mlx5dr_action_destroy(action);
if (err) { if (err)
mlx5_core_err(ns->dev,
"Failed to destroy action (%d)\n", err);
action = NULL; action = NULL;
mlx5_core_err(ns->dev, "Failed to destroy action (%d)\n",
err);
}
} }
ft->fs_dr_table.miss_action = action; ft->fs_dr_table.miss_action = action;
if (old_miss_action) { if (old_miss_action) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册