On Mon, Nov 30, 2026 at 7:52 AM Jedrzej Jagielski <jedr…@intel.com> wrote:
> > Remove the redundant refcount_inc(&ht_old->refcnt) in the > u32_replace_hw_knode() error path during filter update. > > Commit e8d3d78c19be ("net: sched: cls_u32: Undo refcount decrement in case update failed") > added this increment to "undo" a decrement performed by u32_set_parms() > on the original node's linked hash table but apparently this decrement > is already balanced by u32_init_knode(), which increments the same > refcount when cloning the original node: > > u32_init_knode(): refcount_inc() on the old ht_down > u32_set_parms(): refcount_dec() on ht_old > __u32_destroy_key(new): drops new->ht_down > > These cancel out, leaving the original hash table's refcount unchanged. > The additional refcount_inc in the error path has no matching decrement, > leaving the tc_u_hnode refcount permanently elevated by 1. This > prevents the hash table from ever being freed, leaking memory. > > __u32_destroy_key(new) already correctly drops new->ht_down's refcount > (the new linked hash table set by u32_set_parms), so no manual refcount > fixup is needed. > > This is a forward fix for currently dead code, which will be uncovered > by the upcoming patch "net/sched: cls_u32: feed u32_replace_hw_knode() > with correct set of flags". > > Fixes: e8d3d78c19be ("net: sched: cls_u32: Undo refcount decrement in case update failed") > Cc: stab…@vger.kernel.org > Reported-by: Sashiko <sash…@kernel.org> > Closes: https://sashiko.dev/#/patchset/2026…%40intel.com > Signed-off-by: Jedrzej Jagielski <jedr…@intel.com>
Reviewed-by: Jamal Hadi Salim <j…@mojatatu.com> cheers, jamal
> --- > net/sched/cls_u32.c | 8 -------- > 1 file changed, 8 deletions(-) > > diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c > index c544c8e4e876..ae1b6476f921 100644 > --- a/net/sched/cls_u32.c > +++ b/net/sched/cls_u32.c > @@ -954,14 +954,6 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, > err = u32_replace_hw_knode(tp, new, flags, extack); > if (err) { > u32_unbind_filter(tp, new, tb); > - > - if (tb[TCA_U32_LINK]) { > - struct tc_u_hnode *ht_old; > - > - ht_old = rtnl_dereference(n->ht_down); > - if (ht_old) > - refcount_inc(&ht_old->refcnt); > - } > __u32_destroy_key(new); > return err; > } > -- > 2.31.1 >