summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2020-02-04 22:10:12 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-15 00:32:18 +0300
commite79fbd72dca656e3c8f89bb4ebbcc369f5e40774 (patch)
tree37de555b5bbd3be94f2cdce075ba95e3221c039a
parentad998ed96e150faed0d0f148d12d66dd6ce20e9f (diff)
downloadlinux-e79fbd72dca656e3c8f89bb4ebbcc369f5e40774.tar.xz
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>
-rw-r--r--net/sched/cls_tcindex.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 10df2c12a3fb..796b4e1beb12 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -383,7 +383,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
err = tcindex_filter_result_init(&new_filter_result);
if (err < 0)
- goto errout1;
+ goto errout_alloc;
if (old_r)
cr = r->res;
@@ -502,7 +502,6 @@ errout_alloc:
tcindex_free_perfect_hash(cp);
else if (balloc == 2)
kfree(cp->h);
-errout1:
tcf_exts_destroy(&new_filter_result.exts);
errout:
kfree(cp);