net_sched: fix a resource leak in tcindex_set_parms()
authorCong Wang <xiyou.wangcong@gmail.com>
Tue, 4 Feb 2020 19:10:12 +0000 (11:10 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:34:15 +0000 (04:34 -0800)
commit7b3dbf958a1a6ec9e2ef0d3dd58cf0f7964ca8ba
tree7feb876d99bf129d27b5b0f0d8082a36dc22d282
parentaf746042b58d7b06ee910dec48fdb196b60d6180
net_sched: fix a resource leak in tcindex_set_parms()

[ Upstream commit 52b5ae501c045010aeeb1d5ac0373ff161a88291 ]

Jakub noticed there is a potential resource leak in
tcindex_set_parms(): when tcindex_filter_result_init() fails
and it jumps to 'errout1' which doesn't release the memory
and resources allocated by tcindex_alloc_perfect_hash().

We should just jump to 'errout_alloc' which calls
tcindex_free_perfect_hash().

Fixes: b9a24bb76bf6 ("net_sched: properly handle failure case of tcf_exts_init()")
Reported-by: Jakub Kicinski <kuba@kernel.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sched/cls_tcindex.c