Skip to content

Commit 52b5ae5

Browse files
congwangdavem330
authored andcommitted
net_sched: fix a resource leak in tcindex_set_parms()
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: b9a24bb ("net_sched: properly handle failure case of tcf_exts_init()") Reported-by: Jakub Kicinski <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2c22c06 commit 52b5ae5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/sched/cls_tcindex.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
365365

366366
err = tcindex_filter_result_init(&new_filter_result, net);
367367
if (err < 0)
368-
goto errout1;
368+
goto errout_alloc;
369369
if (old_r)
370370
cr = r->res;
371371

@@ -484,7 +484,6 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
484484
tcindex_free_perfect_hash(cp);
485485
else if (balloc == 2)
486486
kfree(cp->h);
487-
errout1:
488487
tcf_exts_destroy(&new_filter_result.exts);
489488
errout:
490489
kfree(cp);

0 commit comments

Comments
 (0)