diff mbox series

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

Message ID 1645022624-2010-1-git-send-email-volodymyr.mytnyk@plvision.eu (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] 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 fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 42 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. 16, 2022, 2:43 p.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>
---
 .../ethernet/marvell/prestera/prestera_flower.c    | 24 ++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

Comments

Jakub Kicinski Feb. 18, 2022, 4:51 a.m. UTC | #1
On Wed, 16 Feb 2022 16:43:44 +0200 Volodymyr Mytnyk wrote:
> +	list_for_each_safe(pos, n, &block->template_list) {
> +		template = list_entry(pos, typeof(*template), list);

nit: list_for_each_entry_safe()

> +		if (template->chain_index == f->common.chain_index) {
> +			/* put the reference to the ruleset kept in create */
> +			prestera_flower_template_free(template);
> +			return;
> +		}
> +	}
Jakub Kicinski Feb. 18, 2022, 4:52 a.m. UTC | #2
On Wed, 16 Feb 2022 16:43:44 +0200 Volodymyr Mytnyk wrote:
> Fixes: fa5d824ce5dd ("net: prestera: acl: add multi-chain support offload")
> 
> Signed-off-by: Volodymyr Mytnyk <vmytnyk@marvell.com>

Ah, and please don't put empty lines between tags.
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..9587707e3148 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_flower.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_flower.c
@@ -12,6 +12,14 @@  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;
@@ -20,9 +28,7 @@  void prestera_flower_template_cleanup(struct prestera_flow_block *block)
 	/* 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);
+		prestera_flower_template_free(template);
 	}
 }
 
@@ -423,7 +429,17 @@  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;
+	struct list_head *pos, *n;
+
+	list_for_each_safe(pos, n, &block->template_list) {
+		template = list_entry(pos, typeof(*template), 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,