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
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 <[email protected]>
Reviewed-by: Leon Romanovsky <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>
  • Loading branch information
zhengchaoshao authored and Saeed Mahameed committed Jul 26, 2023
1 parent aeb6601 commit 5dd7758
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 @@ -564,11 +564,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 5dd7758

Please sign in to comment.