]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
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)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 13 Mar 2020 05:19:20 +0000 (01:19 -0400)
BugLink: https://bugs.launchpad.net/bugs/1867051
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/sched/cls_tcindex.c

index 0323aee03de7efbb99c7943be078765c74dfdf2e..09b7dc5fe7e0a022e46947d18280901e37f40cf6 100644 (file)
@@ -365,7 +365,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
 
        err = tcindex_filter_result_init(&new_filter_result, net);
        if (err < 0)
-               goto errout1;
+               goto errout_alloc;
        if (old_r)
                cr = r->res;
 
@@ -484,7 +484,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);