net/mlx5e: TC, Fix parse_attr leak on branch attr alloc failure
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>
Link: https://patch.msgid.link/20261126122316.599831-1-tariqt@nvidia.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
1 file changed