net/sched: cls_u32: fix possible leak in u32_init_knode()
authorEric Dumazet <edumazet@google.com>
Wed, 13 Apr 2022 17:35:42 +0000 (10:35 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 12:38:53 +0000 (14:38 +0200)
commit58bdbd121a3474b741519f6de6e2a916f391b304
treea11f22d9f5f3ec546349aa133ae260307441c643
parent1b4fb109cc53302ed614bbd31982ee22c605fb40
net/sched: cls_u32: fix possible leak in u32_init_knode()

[ Upstream commit ec5b0f605b105457f257f2870acad4a5d463984b ]

While investigating a related syzbot report,
I found that whenever call to tcf_exts_init()
from u32_init_knode() is failing, we end up
with an elevated refcount on ht->refcnt

To avoid that, only increase the refcount after
all possible errors have been evaluated.

Fixes: b9a24bb76bf6 ("net_sched: properly handle failure case of tcf_exts_init()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sched/cls_u32.c