summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c
diff options
context:
space:
mode:
authorRoi Dayan <roid@nvidia.com>2021-12-05 16:10:35 +0300
committerSaeed Mahameed <saeedm@nvidia.com>2022-01-27 23:37:33 +0300
commiteeed226ed110ed40598e60e29b66643012277be7 (patch)
tree65f7ed875f0b20356d9b287cf83cf916836f8362 /drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c
parent3b49a7edec1df4f7019b3b872124231197267205 (diff)
downloadlinux-eeed226ed110ed40598e60e29b66643012277be7.tar.xz
net/mlx5e: TC, Hold sample_attr on stack instead of pointer
In later commit we are going to instantiate multiple attr instances for flow instead of single attr. Parsing TC sample allocates a new memory but there is no symmetric cleanup in the infrastructure. To avoid asymmetric alloc/free use sample_attr as part of the flow attr and not allocated and held as a pointer. This will avoid a cleanup leak when sample action is not on the first attr. Signed-off-by: Roi Dayan <roid@nvidia.com> Reviewed-by: Oz Shlomo <ozsh@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c
index 0d71e97f4eb9..8f261204fdb4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c
@@ -28,11 +28,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,
struct mlx5e_priv *priv,
struct mlx5_flow_attr *attr)
{
- struct mlx5e_sample_attr *sample_attr;
-
- sample_attr = kzalloc(sizeof(*attr->sample_attr), GFP_KERNEL);
- if (!sample_attr)
- return -ENOMEM;
+ struct mlx5e_sample_attr *sample_attr = &attr->sample_attr;
sample_attr->rate = act->sample.rate;
sample_attr->group_num = act->sample.psample_group->group_num;
@@ -40,7 +36,6 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,
if (act->sample.truncate)
sample_attr->trunc_size = act->sample.trunc_size;
- attr->sample_attr = sample_attr;
flow_flag_set(parse_state->flow, SAMPLE);
return 0;