Re: [PATCH] net/mlx5e: TC, release meter if rule offload fails
From: Jianbo Liu
Date: Mon Nov 09 2026 - 22:48:57 EST
On 11/7/2026 9:05 PM, netdev-bot+sashiko@xxxxxxxxxx wrote:
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
[ ... ]
+ rule = mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
+ if (IS_ERR(rule) && meter_added)
+ mlx5e_tc_del_flow_meter(esw, attr);
[Severity: Medium]
Can this lead to a double free of the post meter and an extra meter put?
[ ... ]
Would it help to set attr->meter_attr.meter and
attr->meter_attr.post_meter to NULL, and undo the attr->dest_ft change,
after mlx5e_tc_del_flow_meter() in this failure path? A later unoffload
would then skip the meter release.
Hi Wentao,
Thanks for the fix, the leak is real. This comment is valid too:
mlx5e_tc_del_flow_meter() leaves the pointers set, and
mlx5e_tc_rule_unoffload() releases the meter whenever
attr->meter_attr.meter is non-NULL. After a failed re-offload in
mlx5e_reoffload_encap() the flow is still marked OFFLOADED, so the next
unoffload releases the meter and post meter a second time.
Please clear both pointers in mlx5e_tc_del_flow_meter() in v2. The
dest_ft part is not needed, the next mlx5e_tc_add_flow_meter() sets it
again before it is used.
Thanks,
Jianbo