Commit b05d0cfa authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxsw: acl: Fix mlxsw_afa_block_commit error path

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Fixes: 4cda7d8d ("mlxsw: core: Introduce flexible actions support")
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Acked-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9a9a7a57
...@@ -356,9 +356,9 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block) ...@@ -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 *set = block->cur_set;
struct mlxsw_afa_set *prev_set; struct mlxsw_afa_set *prev_set;
int err;
block->cur_set = NULL; block->cur_set = NULL;
block->finished = true;
/* Go over all linked sets starting from last /* Go over all linked sets starting from last
* and try to find existing set in the hash table. * and try to find existing set in the hash table.
...@@ -368,10 +368,12 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block) ...@@ -368,10 +368,12 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block)
do { do {
prev_set = set->prev; prev_set = set->prev;
set = mlxsw_afa_set_get(block->afa, set); set = mlxsw_afa_set_get(block->afa, set);
if (IS_ERR(set)) { if (IS_ERR(set))
err = PTR_ERR(set); /* No rollback is needed since the chain is
goto rollback; * in consistent state and mlxsw_afa_block_destroy
} * will take care of putting it away.
*/
return PTR_ERR(set);
if (prev_set) { if (prev_set) {
prev_set->next = set; prev_set->next = set;
mlxsw_afa_set_next_set(prev_set, set->kvdl_index); mlxsw_afa_set_next_set(prev_set, set->kvdl_index);
...@@ -380,13 +382,7 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block) ...@@ -380,13 +382,7 @@ int mlxsw_afa_block_commit(struct mlxsw_afa_block *block)
} while (prev_set); } while (prev_set);
block->first_set = set; block->first_set = set;
block->finished = true;
return 0; return 0;
rollback:
while ((set = set->next))
mlxsw_afa_set_put(block->afa, set);
return err;
} }
EXPORT_SYMBOL(mlxsw_afa_block_commit); EXPORT_SYMBOL(mlxsw_afa_block_commit);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment