public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins()
@ 2026-01-23  6:57 Zilin Guan
  2026-01-23  8:09 ` Maxime Chevallier
  2026-01-25 21:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Zilin Guan @ 2026-01-23  6:57 UTC (permalink / raw)
  To: marcin.s.wojtas
  Cc: linux, andrew+netdev, davem, edumazet, kuba, pabeni,
	maxime.chevallier, netdev, linux-kernel, jianhao.xu, Zilin Guan

In mvpp2_ethtool_cls_rule_ins(), the ethtool_rule is allocated by
ethtool_rx_flow_rule_create(). If the subsequent conversion to flow
type fails, the function jumps to the clean_rule label.

However, the clean_rule label only frees efs, skipping the cleanup
of ethtool_rule, which leads to a memory leak.

Fix this by jumping to the clean_eth_rule label, which properly calls
ethtool_rx_flow_rule_destroy() before freeing efs.

Compile tested only. Issue found using a prototype static analysis tool
and code review.

Fixes: f4f1ba18195d ("net: mvpp2: cls: Report an error for unsupported flow types")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---
Changes in v2:
- Cc the author of the commit under Fixes.

 drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
index 44b201817d94..c116da7d7f18 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
@@ -1389,7 +1389,7 @@ int mvpp2_ethtool_cls_rule_ins(struct mvpp2_port *port,
 	efs->rule.flow_type = mvpp2_cls_ethtool_flow_to_type(info->fs.flow_type);
 	if (efs->rule.flow_type < 0) {
 		ret = efs->rule.flow_type;
-		goto clean_rule;
+		goto clean_eth_rule;
 	}
 
 	ret = mvpp2_cls_rfs_parse_rule(&efs->rule);
-- 
2.34.1


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

* Re: [PATCH net v2] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins()
  2026-01-23  6:57 [PATCH net v2] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins() Zilin Guan
@ 2026-01-23  8:09 ` Maxime Chevallier
  2026-01-25 21:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Chevallier @ 2026-01-23  8:09 UTC (permalink / raw)
  To: Zilin Guan, marcin.s.wojtas
  Cc: linux, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, jianhao.xu

Hi,

On 23/01/2026 07:57, Zilin Guan wrote:
> In mvpp2_ethtool_cls_rule_ins(), the ethtool_rule is allocated by
> ethtool_rx_flow_rule_create(). If the subsequent conversion to flow
> type fails, the function jumps to the clean_rule label.
> 
> However, the clean_rule label only frees efs, skipping the cleanup
> of ethtool_rule, which leads to a memory leak.
> 
> Fix this by jumping to the clean_eth_rule label, which properly calls
> ethtool_rx_flow_rule_destroy() before freeing efs.
> 
> Compile tested only. Issue found using a prototype static analysis tool
> and code review.

Thanks for clarifying how you found that

> 
> Fixes: f4f1ba18195d ("net: mvpp2: cls: Report an error for unsupported flow types")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>

Change is fine, thanks for fixing this.

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Maxime


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

* Re: [PATCH net v2] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins()
  2026-01-23  6:57 [PATCH net v2] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins() Zilin Guan
  2026-01-23  8:09 ` Maxime Chevallier
@ 2026-01-25 21:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-25 21:20 UTC (permalink / raw)
  To: Zilin Guan
  Cc: marcin.s.wojtas, linux, andrew+netdev, davem, edumazet, kuba,
	pabeni, maxime.chevallier, netdev, linux-kernel, jianhao.xu

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 23 Jan 2026 06:57:16 +0000 you wrote:
> In mvpp2_ethtool_cls_rule_ins(), the ethtool_rule is allocated by
> ethtool_rx_flow_rule_create(). If the subsequent conversion to flow
> type fails, the function jumps to the clean_rule label.
> 
> However, the clean_rule label only frees efs, skipping the cleanup
> of ethtool_rule, which leads to a memory leak.
> 
> [...]

Here is the summary with links:
  - [net,v2] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins()
    https://git.kernel.org/netdev/net/c/09f979d1f312

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] 3+ messages in thread

end of thread, other threads:[~2026-01-25 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23  6:57 [PATCH net v2] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins() Zilin Guan
2026-01-23  8:09 ` Maxime Chevallier
2026-01-25 21:20 ` 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