Commit d14cbfc8 authored by John Fastabend's avatar John Fastabend Committed by David S. Miller

net: sched: cls_cgroup fix possible memory leak of 'new'

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
head:   54996b52
commit: c7953ef2 [625/646] net: sched: cls_cgroup use RCU

net/sched/cls_cgroup.c:130 cls_cgroup_change() warn: possible memory leak of 'new'
net/sched/cls_cgroup.c:135 cls_cgroup_change() warn: possible memory leak of 'new'
net/sched/cls_cgroup.c:139 cls_cgroup_change() warn: possible memory leak of 'new'

Fixes: c7953ef2 ("net: sched: cls_cgroup use RCU")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarJohn Fastabend <john.r.fastabend@intel.com>
Acked-by: default avatarCong Wang <cwang@twopensource.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a96366bf
...@@ -127,16 +127,18 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, ...@@ -127,16 +127,18 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
err = nla_parse_nested(tb, TCA_CGROUP_MAX, tca[TCA_OPTIONS], err = nla_parse_nested(tb, TCA_CGROUP_MAX, tca[TCA_OPTIONS],
cgroup_policy); cgroup_policy);
if (err < 0) if (err < 0)
return err; goto errout;
tcf_exts_init(&e, TCA_CGROUP_ACT, TCA_CGROUP_POLICE); tcf_exts_init(&e, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, ovr); err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, ovr);
if (err < 0) if (err < 0)
return err; goto errout;
err = tcf_em_tree_validate(tp, tb[TCA_CGROUP_EMATCHES], &t); err = tcf_em_tree_validate(tp, tb[TCA_CGROUP_EMATCHES], &t);
if (err < 0) if (err < 0) {
return err; tcf_exts_destroy(tp, &e);
goto errout;
}
tcf_exts_change(tp, &new->exts, &e); tcf_exts_change(tp, &new->exts, &e);
tcf_em_tree_change(tp, &new->ematches, &t); tcf_em_tree_change(tp, &new->ematches, &t);
...@@ -145,6 +147,9 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, ...@@ -145,6 +147,9 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
if (head) if (head)
call_rcu(&head->rcu, cls_cgroup_destroy_rcu); call_rcu(&head->rcu, cls_cgroup_destroy_rcu);
return 0; return 0;
errout:
kfree(new);
return err;
} }
static void cls_cgroup_destroy(struct tcf_proto *tp) static void cls_cgroup_destroy(struct tcf_proto *tp)
......
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