* [PATCH net] net/mlx5e: TC, Fix parse_attr leak on branch attr alloc failure
@ 2026-11-26 12:23 Tariq Toukan
2026-11-26 12:29 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2026-11-26 12:23 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni, Willem de Bruijn
Cc: Gal Pressman, Jianbo Liu, Leon Romanovsky, linux-rdma, Mark Bloch,
Oz Shlomo, Roi Dayan, Saeed Mahameed, Tariq Toukan
alloc_branch_attr() gets the branch attribute from
mlx5e_clone_flow_attr_for_post_act(), which also allocates its
parse_attr. When the branch action cannot be offloaded, the error path
frees the attribute but not its parse_attr, leaking it.
This happens, for example, when a police action's conform and exceed
actions are both jumps: the exceed action fails with "Cannot offload
flows with nested jumps".
Free the parse_attr too.
Found by LLM-assisted code inspection, while reviewing a fix for a
double free on the same error path.
Reproduced on ConnectX-6 Dx in switchdev mode, with kmemleak, by
failing 50 times to offload such a filter on the uplink representor:
tc filter add dev $UPLINK ingress protocol ip flower skip_sw \
dst_ip 192.0.2.2 action police rate 1mbit burst 20k \
conform-exceed jump 1 / jump 1 action pass action drop
Without this patch, kmemleak reported 29 unreferenced 4096-byte
objects, all allocated by mlx5e_clone_flow_attr_for_post_act() from
alloc_branch_attr(). With it, kmemleak reported none.
Fixes: f86488cb4685 ("net/mlx5e: TC, initialize branch flow attributes")
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 011741553f5b..142cccba907e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -3915,7 +3915,8 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow,
return err;
out_err:
- kfree(*cond_attr);
+ kvfree(attr->parse_attr);
+ kfree(attr);
*cond_attr = NULL;
return err;
}
base-commit: cc7fe6e741730fef549e484379281736d32746f0
--
2.44.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net/mlx5e: TC, Fix parse_attr leak on branch attr alloc failure
2026-11-26 12:23 [PATCH net] net/mlx5e: TC, Fix parse_attr leak on branch attr alloc failure Tariq Toukan
@ 2026-11-26 12:29 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-26 12:29 UTC (permalink / raw)
To: Tariq Toukan; +Cc: linux-rdma
> alloc_branch_attr() gets the branch attribute from
> mlx5e_clone_flow_attr_for_post_act(), which also allocates its
> parse_attr. When the branch action cannot be offloaded, the error path
> frees the attribute but not its parse_attr, leaking it.
>
> This happens, for example, when a police action's conform and exceed
> actions are both jumps: the exceed action fails with "Cannot offload
> flows with nested jumps".
>
> Free the parse_attr too.
>
> Found by LLM-assisted code inspection, while reviewing a fix for a
> double free on the same error path.
>
> Reproduced on ConnectX-6 Dx in switchdev mode, with kmemleak, by
> failing 50 times to offload such a filter on the uplink representor:
>
> tc filter add dev $UPLINK ingress protocol ip flower skip_sw \
> dst_ip 192.0.2.2 action police rate 1mbit burst 20k \
> conform-exceed jump 1 / jump 1 action pass action drop
>
> Without this patch, kmemleak reported 29 unreferenced 4096-byte
> objects, all allocated by mlx5e_clone_flow_attr_for_post_act() from
> alloc_branch_attr(). With it, kmemleak reported none.
>
> Fixes: f86488cb4685 ("net/mlx5e: TC, initialize branch flow attributes")
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126122316.599831-1-tariqt@nvidia.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 12:23 [PATCH net] net/mlx5e: TC, Fix parse_attr leak on branch attr alloc failure Tariq Toukan
2026-11-26 12:29 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox