Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 4cda7d8d7098 ("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>

authored by

Jiri Pirko and committed by
David S. Miller
b05d0cfa 9a9a7a57

+7 -11
+7 -11
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
··· 356 356 { 357 357 struct mlxsw_afa_set *set = block->cur_set; 358 358 struct mlxsw_afa_set *prev_set; 359 - int err; 360 359 361 360 block->cur_set = NULL; 361 + block->finished = true; 362 362 363 363 /* Go over all linked sets starting from last 364 364 * and try to find existing set in the hash table. ··· 368 368 do { 369 369 prev_set = set->prev; 370 370 set = mlxsw_afa_set_get(block->afa, set); 371 - if (IS_ERR(set)) { 372 - err = PTR_ERR(set); 373 - goto rollback; 374 - } 371 + if (IS_ERR(set)) 372 + /* No rollback is needed since the chain is 373 + * in consistent state and mlxsw_afa_block_destroy 374 + * will take care of putting it away. 375 + */ 376 + return PTR_ERR(set); 375 377 if (prev_set) { 376 378 prev_set->next = set; 377 379 mlxsw_afa_set_next_set(prev_set, set->kvdl_index); ··· 382 380 } while (prev_set); 383 381 384 382 block->first_set = set; 385 - block->finished = true; 386 383 return 0; 387 - 388 - rollback: 389 - while ((set = set->next)) 390 - mlxsw_afa_set_put(block->afa, set); 391 - return err; 392 384 } 393 385 EXPORT_SYMBOL(mlxsw_afa_block_commit); 394 386