diff mbox series

[net-next,mlxsw,2/2] mlxsw: core_acl_flex_actions: Remove redundant resource destruction

Message ID 20180725083744.994-3-nird@mellanox.com (mailing list archive)
State Changes Requested
Delegated to: Jiří Pírko
Headers show
Series mlxsw: Fix ACL actions error condition handling | expand

Commit Message

Nir Dotan July 25, 2018, 8:37 a.m. UTC
Some ACL actions require the allocation of a separate resource
prior to applying the action itself. When facing an error condition
during the setup phase of the action, resource was destroyed.
This was found to be redundant and also harmful for mirror actions,
as error condition always leads to destruction of the rule and all
of its resources.

Signed-off-by: Nir Dotan <nird@mellanox.com>
---
 .../ethernet/mellanox/mlxsw/core_acl_flex_actions.c  | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
index 9c87363..c3401cf 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
@@ -962,14 +962,10 @@  mlxsw_afa_block_append_mirror(struct mlxsw_afa_block *block, u8 local_in_port,
 	err = mlxsw_afa_block_append_allocated_mirror(block, mirror->span_id);
 	if (err) {
 		NL_SET_ERR_MSG_MOD(extack, "Cannot append mirror action");
-		goto err_append_allocated_mirror;
+		return err;
 	}
 
 	return 0;
-
-err_append_allocated_mirror:
-	mlxsw_afa_mirror_destroy(block, mirror);
-	return err;
 }
 EXPORT_SYMBOL(mlxsw_afa_block_append_mirror);
 
@@ -1019,7 +1015,6 @@  int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
 	struct mlxsw_afa_fwd_entry_ref *fwd_entry_ref;
 	u32 kvdl_index;
 	char *act;
-	int err;
 
 	if (in_port) {
 		NL_SET_ERR_MSG_MOD(extack, "Forwarding to ingress port is not supported");
@@ -1035,17 +1030,12 @@  int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
 	act = mlxsw_afa_block_append_action(block, MLXSW_AFA_FORWARD_CODE,
 					    MLXSW_AFA_FORWARD_SIZE);
 	if (!act) {
-		err = -ENOBUFS;
 		NL_SET_ERR_MSG_MOD(extack, "Cannot append forward action");
-		goto err_append_action;
+		return -ENOBUFS;
 	}
 	mlxsw_afa_forward_pack(act, MLXSW_AFA_FORWARD_TYPE_PBS,
 			       kvdl_index, in_port);
 	return 0;
-
-err_append_action:
-	mlxsw_afa_fwd_entry_ref_destroy(block, fwd_entry_ref);
-	return err;
 }
 EXPORT_SYMBOL(mlxsw_afa_block_append_fwd);
 
@@ -1117,15 +1107,11 @@  int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block,
 	err = mlxsw_afa_block_append_allocated_counter(block, counter_index);
 	if (err) {
 		NL_SET_ERR_MSG_MOD(extack, "Cannot append count action");
-		goto err_append_allocated_counter;
+		return err;
 	}
 	if (p_counter_index)
 		*p_counter_index = counter_index;
 	return 0;
-
-err_append_allocated_counter:
-	mlxsw_afa_counter_destroy(block, counter);
-	return err;
 }
 EXPORT_SYMBOL(mlxsw_afa_block_append_counter);