diff mbox series

[net-next,v2] net: prestera: flower: fix destroy tmpl in chain

Message ID 1645177190-6949-1-git-send-email-volodymyr.mytnyk@plvision.eu (mailing list archive)
State Accepted
Commit b3ae2d350ddfd5aeb04de29c333d6639aeb1dae2
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] net: prestera: flower: fix destroy tmpl in chain | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 44 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Volodymyr Mytnyk Feb. 18, 2022, 9:39 a.m. UTC
From: Volodymyr Mytnyk <vmytnyk@marvell.com>

Fix flower destroy template callback to release template
only for specific tc chain instead of all chain tempaltes.

The issue was intruduced by previous commit that introduced
multi-chain support.

Fixes: fa5d824ce5dd ("net: prestera: acl: add multi-chain support offload")
Signed-off-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
---

V1->V2:
    use list_for_each_entry_safe instead of list_for_each_safe
    remove empty lines between tags

 .../ethernet/marvell/prestera/prestera_flower.c    | 28 +++++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 19, 2022, 4:40 p.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 18 Feb 2022 11:39:49 +0200 you wrote:
> From: Volodymyr Mytnyk <vmytnyk@marvell.com>
> 
> Fix flower destroy template callback to release template
> only for specific tc chain instead of all chain tempaltes.
> 
> The issue was intruduced by previous commit that introduced
> multi-chain support.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: prestera: flower: fix destroy tmpl in chain
    https://git.kernel.org/netdev/net-next/c/b3ae2d350ddf

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_flower.c b/drivers/net/ethernet/marvell/prestera/prestera_flower.c
index 580fb986496a..921959a980ee 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_flower.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_flower.c
@@ -12,18 +12,21 @@  struct prestera_flower_template {
 	u32 chain_index;
 };
 
+static void
+prestera_flower_template_free(struct prestera_flower_template *template)
+{
+	prestera_acl_ruleset_put(template->ruleset);
+	list_del(&template->list);
+	kfree(template);
+}
+
 void prestera_flower_template_cleanup(struct prestera_flow_block *block)
 {
-	struct prestera_flower_template *template;
-	struct list_head *pos, *n;
+	struct prestera_flower_template *template, *tmp;
 
 	/* put the reference to all rulesets kept in tmpl create */
-	list_for_each_safe(pos, n, &block->template_list) {
-		template = list_entry(pos, typeof(*template), list);
-		prestera_acl_ruleset_put(template->ruleset);
-		list_del(&template->list);
-		kfree(template);
-	}
+	list_for_each_entry_safe(template, tmp, &block->template_list, list)
+		prestera_flower_template_free(template);
 }
 
 static int
@@ -423,7 +426,14 @@  int prestera_flower_tmplt_create(struct prestera_flow_block *block,
 void prestera_flower_tmplt_destroy(struct prestera_flow_block *block,
 				   struct flow_cls_offload *f)
 {
-	prestera_flower_template_cleanup(block);
+	struct prestera_flower_template *template, *tmp;
+
+	list_for_each_entry_safe(template, tmp, &block->template_list, list)
+		if (template->chain_index == f->common.chain_index) {
+			/* put the reference to the ruleset kept in create */
+			prestera_flower_template_free(template);
+			return;
+		}
 }
 
 int prestera_flower_stats(struct prestera_flow_block *block,