All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net] net_sched: fix a resource leak in tcindex_set_parms()
@ 2020-02-04 19:10 Cong Wang
  2020-02-05 13:13 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2020-02-04 19:10 UTC (permalink / raw)
  To: netdev; +Cc: Cong Wang, Jakub Kicinski, Jamal Hadi Salim, Jiri Pirko

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>
---
 net/sched/cls_tcindex.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 0323aee03de7..09b7dc5fe7e0 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -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 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
 		tcindex_free_perfect_hash(cp);
 	else if (balloc == 2)
 		kfree(cp->h);
-errout1:
 	tcf_exts_destroy(&new_filter_result.exts);
 errout:
 	kfree(cp);
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch net] net_sched: fix a resource leak in tcindex_set_parms()
  2020-02-04 19:10 [Patch net] net_sched: fix a resource leak in tcindex_set_parms() Cong Wang
@ 2020-02-05 13:13 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-02-05 13:13 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, kuba, jhs, jiri

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Tue,  4 Feb 2020 11:10:12 -0800

> 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>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-05 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 19:10 [Patch net] net_sched: fix a resource leak in tcindex_set_parms() Cong Wang
2020-02-05 13:13 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.