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 Reviewed-by: Jianbo Liu --- 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