[PATCH net] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins()

Zilin Guan posted 1 patch 2 weeks, 4 days ago
There is a newer version of this series
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH net] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins()
Posted by Zilin Guan 2 weeks, 4 days ago
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>
---
 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
Re: [PATCH net] net: mvpp2: cls: Fix memory leak in mvpp2_ethtool_cls_rule_ins()
Posted by Jakub Kicinski 2 weeks, 3 days ago
On Wed, 21 Jan 2026 14:06:00 +0000 Zilin Guan wrote:
> Fixes: f4f1ba18195d ("net: mvpp2: cls: Report an error for unsupported flow types")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>

Please feed the _patch_ to the get_maintainter script.
The author of the commit under Fixes should be cced, please repost.
-- 
pw-bot: cr