All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, idosch@mellanox.com, eladr@mellanox.com,
	mlxsw@mellanox.com, dan.carpenter@oracle.com
Subject: [patch net-next] mlxsw: acl: Fix mlxsw_afa_block_commit error path
Date: Wed,  8 Feb 2017 10:39:16 +0100	[thread overview]
Message-ID: <1486546756-1950-1-git-send-email-jiri@resnulli.us> (raw)

From: Jiri Pirko <jiri@mellanox.com>

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>
---
 .../ethernet/mellanox/mlxsw/core_acl_flex_actions.c    | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

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 34e2fef..42bb18f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
@@ -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);
 
-- 
2.7.4

             reply	other threads:[~2017-02-08  9:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08  9:39 Jiri Pirko [this message]
2017-02-08 20:14 ` [patch net-next] mlxsw: acl: Fix mlxsw_afa_block_commit error path David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1486546756-1950-1-git-send-email-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=eladr@mellanox.com \
    --cc=idosch@mellanox.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.