Skip to content

Commit

Permalink
net/mlx5: DR, fix memory leak in mlx5dr_cmd_create_reformat_ctx
Browse files Browse the repository at this point in the history
[ Upstream commit 5dd7758 ]

when mlx5_cmd_exec failed in mlx5dr_cmd_create_reformat_ctx, the memory
pointed by 'in' is not released, which will cause memory leak. Move memory
release after mlx5_cmd_exec.

Fixes: 1d91864 ("net/mlx5: DR, Add direct rule command utilities")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
zhengchaoshao authored and gregkh committed Aug 11, 2023
1 parent c818fff commit 3169c38
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,12 @@ int mlx5dr_cmd_create_reformat_ctx(struct mlx5_core_dev *mdev,

err = mlx5_cmd_exec(mdev, in, inlen, out, sizeof(out));
if (err)
return err;
goto err_free_in;

*reformat_id = MLX5_GET(alloc_packet_reformat_context_out, out, packet_reformat_id);
kvfree(in);

err_free_in:
kvfree(in);
return err;
}

Expand Down

0 comments on commit 3169c38

Please sign in to comment.