summaryrefslogtreecommitdiff
path: root/net/sched
diff options
context:
space:
mode:
authorVictor Nogueira <victor@mojatatu.com>2023-07-13 21:05:12 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-27 09:50:41 +0300
commit2256b27f542bd245b1692fc026ebefe061cc6335 (patch)
tree466b7d9f252c2373236cd0dd928ec6352121e200 /net/sched
parenta9345793469b65ee5ba7b033239916c2a67d3dd4 (diff)
downloadlinux-2256b27f542bd245b1692fc026ebefe061cc6335.tar.xz
net: sched: cls_u32: Undo refcount decrement in case update failed
[ Upstream commit e8d3d78c19be0264a5692bed477c303523aead31 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/cls_u32.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 7cfbcd518084..1280736a7b92 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -926,6 +926,13 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
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)
+ ht_old->refcnt++;
+ }
__u32_destroy_key(new);
return err;
}