Skip to content

Commit

Permalink
net/mlx5: Fix leak upon failure of rule creation
Browse files Browse the repository at this point in the history
When creation of a new rule that requires allocation of an FTE fails,
need to call to tree_put_node on the FTE in order to release its'
resource.

Fixes: cefc235 ("net/mlx5: Fix FTE cleanup")
Signed-off-by: Maor Gottlieb <[email protected]>
Reviewed-by: Alaa Hleihel <[email protected]>
Reviewed-by: Mark Bloch <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>
  • Loading branch information
maorgottlieb authored and Saeed Mahameed committed Feb 2, 2021
1 parent ed5e83a commit a5bfe6b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,
if (!fte_tmp)
continue;
rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte_tmp);
/* No error check needed here, because insert_fte() is not called */
up_write_ref_node(&fte_tmp->node, false);
tree_put_node(&fte_tmp->node, false);
kmem_cache_free(steering->ftes_cache, fte);
Expand Down Expand Up @@ -1812,6 +1813,8 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,
up_write_ref_node(&g->node, false);
rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte);
up_write_ref_node(&fte->node, false);
if (IS_ERR(rule))
tree_put_node(&fte->node, false);
return rule;
}
rule = ERR_PTR(-ENOENT);
Expand Down Expand Up @@ -1910,6 +1913,8 @@ _mlx5_add_flow_rules(struct mlx5_flow_table *ft,
up_write_ref_node(&g->node, false);
rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte);
up_write_ref_node(&fte->node, false);
if (IS_ERR(rule))
tree_put_node(&fte->node, false);
tree_put_node(&g->node, false);
return rule;

Expand Down

0 comments on commit a5bfe6b

Please sign in to comment.