Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: sched: cls_u32: Undo refcount decrement in case update failed

In the case of an update, when TCA_U32_LINK is set, u32_set_parms will
decrement the refcount of the ht_down (struct tc_u_hnode) pointer
present in the older u32 filter which we are replacing. However, if
u32_replace_hw_knode errors out, the update command fails and that
ht_down pointer continues decremented. To fix that, when
u32_replace_hw_knode fails, check if ht_down's refcount was decremented
and undo the decrement.

Fixes: d34e3e181395 ("net: cls_u32: Add support for skip-sw flag to tc u32 classifier.")
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Victor Nogueira and committed by
David S. Miller
e8d3d78c 9cb36fae

+7
+7
net/sched/cls_u32.c
··· 928 928 if (err) { 929 929 u32_unbind_filter(tp, new, tb); 930 930 931 + if (tb[TCA_U32_LINK]) { 932 + struct tc_u_hnode *ht_old; 933 + 934 + ht_old = rtnl_dereference(n->ht_down); 935 + if (ht_old) 936 + ht_old->refcnt++; 937 + } 931 938 __u32_destroy_key(new); 932 939 return err; 933 940 }