public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: prestera: flower: fix destroy tmpl in chain
@ 2022-02-18  9:39 Volodymyr Mytnyk
  2022-02-19 16:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Volodymyr Mytnyk @ 2022-02-18  9:39 UTC (permalink / raw)
  To: netdev, Jakub Kicinski
  Cc: Taras Chornyi, Mickey Rachamim, Serhiy Pshyk, Volodymyr Mytnyk,
	Taras Chornyi, David S. Miller, linux-kernel

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(-)

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,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next v2] net: prestera: flower: fix destroy tmpl in chain
  2022-02-18  9:39 [PATCH net-next v2] net: prestera: flower: fix destroy tmpl in chain Volodymyr Mytnyk
@ 2022-02-19 16:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-19 16:40 UTC (permalink / raw)
  To: Volodymyr Mytnyk
  Cc: netdev, kuba, taras.chornyi, mickeyr, serhiy.pshyk, vmytnyk,
	tchornyi, davem, linux-kernel

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-19 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-18  9:39 [PATCH net-next v2] net: prestera: flower: fix destroy tmpl in chain Volodymyr Mytnyk
2022-02-19 16:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox