Skip to content

Commit

Permalink
mlxsw: acl: Fix mlxsw_afa_block_commit error path
Browse files Browse the repository at this point in the history
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.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 4cda7d8 ("mlxsw: core: Introduce flexible actions support")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Feb 8, 2017
1 parent 9a9a7a5 commit b05d0cf
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit b05d0cf

Please sign in to comment.