net/mlx5: HWS, fixed double free in error flow of definer layout

Fix error flow bug that could lead to double free of a buffer
during a failure to calculate a suitable definer layout.

Fixes: 74a778b4a63f ("net/mlx5: HWS, added definers handling")
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Itamar Gozlan <igozlan@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Yevgeny Kliteynik 2024-10-15 12:32:02 +03:00 committed by Paolo Abeni
parent 65b4eb9f3d
commit 5aa2184e29

View File

@ -1925,7 +1925,7 @@ mlx5hws_definer_calc_layout(struct mlx5hws_context *ctx,
ret = hws_definer_conv_match_params_to_hl(ctx, mt, match_hl); ret = hws_definer_conv_match_params_to_hl(ctx, mt, match_hl);
if (ret) { if (ret) {
mlx5hws_err(ctx, "Failed to convert items to header layout\n"); mlx5hws_err(ctx, "Failed to convert items to header layout\n");
goto free_fc; goto free_match_hl;
} }
/* Find the match definer layout for header layout match union */ /* Find the match definer layout for header layout match union */
@ -1946,7 +1946,7 @@ mlx5hws_definer_calc_layout(struct mlx5hws_context *ctx,
free_fc: free_fc:
kfree(mt->fc); kfree(mt->fc);
free_match_hl:
kfree(match_hl); kfree(match_hl);
return ret; return ret;
} }