Skip to contentSkip to conversation

mlxsw: acl: Fix mlxsw_afa_block_commit error path

PATCH Applied Jiri Pirko 2 participants 2 messages Feb 8, 2017

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 mlxsw: acl: Fix mlxsw_afa_block_commit error path

From: Jiri Pirko <[email protected]>

No rollback is needed since the chain is in consistent state and mlxsw_afa_block_destroy() will take care of putting it away. So remove the one we have now which is wrong. Also move the set of 'finished' flag to the beginning of the function, because the block is certainly unusable for future action addition no matter if the function succeeds or not.

Fixes 4cda7d8d7098 ("mlxsw: core: Introduce flexible actions support")
---
 .../ethernet/mellanox/mlxsw/core_acl_flex_actions.c    | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c +7 -11
index 34e2fef..42bb18f 100644
@@ -356,9 +356,9 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block)
 {
 	struct mlxsw_afa_set *set = block->cur_set;
 	struct mlxsw_afa_set *prev_set;
-	int err;
 
 	block->cur_set = NULL;
+	block->finished = true;
 
 	/* Go over all linked sets starting from last
 	 * and try to find existing set in the hash table.
@@ -368,10 +368,12 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block)
 	do {
 		prev_set = set->prev;
 		set = mlxsw_afa_set_get(block->afa, set);
-		if (IS_ERR(set)) {
-			err = PTR_ERR(set);
-			goto rollback;
-		}
+		if (IS_ERR(set))
+			/* No rollback is needed since the chain is
+			 * in consistent state and mlxsw_afa_block_destroy
+			 * will take care of putting it away.
+			 */
+			return PTR_ERR(set);
 		if (prev_set) {
 			prev_set->next = set;
 			mlxsw_afa_set_next_set(prev_set, set->kvdl_index);
@@ -380,13 +382,7 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block)
 	} while (prev_set);
 
 	block->first_set = set;
-	block->finished = true;
 	return 0;
-
-rollback:
-	while ((set = set->next))
-		mlxsw_afa_set_put(block->afa, set);
-	return err;
 }
 EXPORT_SYMBOL(mlxsw_afa_block_commit);
 
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

From: Jiri Pirko <[email protected]>
Date: Wed, 8 Feb 2017 10:39:16 +0100

Quoted 8 lines

From: Jiri Pirko <[email protected]>

No rollback is needed since the chain is in consistent state and mlxsw_afa_block_destroy() will take care of putting it away. So remove the one we have now which is wrong. Also move the set of 'finished' flag to the beginning of the function, because the block is certainly unusable for future action addition no matter if the function succeeds or not.

Quoted 4 lines
Fixes 4cda7d8d7098 ("mlxsw: core: Introduce flexible actions support")

Applied.