Commit 44b75e43 authored by WANG Cong's avatar WANG Cong Committed by David S. Miller

net_sched: fix memory leak in cls_tcindex

Fixes: commit 331b7292 ("net: sched: RCU cls_tcindex")
Cc: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Acked-By: default avatarJohn Fastabend <john.r.fastabend@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c1f570a6
...@@ -242,8 +242,10 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, ...@@ -242,8 +242,10 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
* perfect hash and hash pointers from old data. * perfect hash and hash pointers from old data.
*/ */
cp = kzalloc(sizeof(*cp), GFP_KERNEL); cp = kzalloc(sizeof(*cp), GFP_KERNEL);
if (!cp) if (!cp) {
return -ENOMEM; err = -ENOMEM;
goto errout;
}
cp->mask = p->mask; cp->mask = p->mask;
cp->shift = p->shift; cp->shift = p->shift;
...@@ -257,6 +259,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, ...@@ -257,6 +259,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
sizeof(*r) * cp->hash, GFP_KERNEL); sizeof(*r) * cp->hash, GFP_KERNEL);
if (!cp->perfect) if (!cp->perfect)
goto errout; goto errout;
balloc = 1;
} }
cp->h = p->h; cp->h = p->h;
...@@ -282,9 +285,9 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, ...@@ -282,9 +285,9 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
if (cp->perfect) { if (cp->perfect) {
if (!valid_perfect_hash(cp) || if (!valid_perfect_hash(cp) ||
cp->hash > cp->alloc_hash) cp->hash > cp->alloc_hash)
goto errout; goto errout_alloc;
} else if (cp->h && cp->hash != cp->alloc_hash) { } else if (cp->h && cp->hash != cp->alloc_hash) {
goto errout; goto errout_alloc;
} }
err = -EINVAL; err = -EINVAL;
...@@ -311,7 +314,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, ...@@ -311,7 +314,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
*/ */
if (cp->perfect || valid_perfect_hash(cp)) if (cp->perfect || valid_perfect_hash(cp))
if (handle >= cp->alloc_hash) if (handle >= cp->alloc_hash)
goto errout; goto errout_alloc;
err = -ENOMEM; err = -ENOMEM;
...@@ -321,7 +324,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, ...@@ -321,7 +324,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
cp->perfect = kcalloc(cp->hash, sizeof(*r), GFP_KERNEL); cp->perfect = kcalloc(cp->hash, sizeof(*r), GFP_KERNEL);
if (!cp->perfect) if (!cp->perfect)
goto errout; goto errout_alloc;
for (i = 0; i < cp->hash; i++) for (i = 0; i < cp->hash; i++)
tcf_exts_init(&cp->perfect[i].exts, tcf_exts_init(&cp->perfect[i].exts,
TCA_TCINDEX_ACT, TCA_TCINDEX_ACT,
...@@ -335,7 +338,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, ...@@ -335,7 +338,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
GFP_KERNEL); GFP_KERNEL);
if (!hash) if (!hash)
goto errout; goto errout_alloc;
cp->h = hash; cp->h = hash;
balloc = 2; balloc = 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment