net_sched: properly handle failure case of tcf_exts_init()
After commit 22dc13c837
("net_sched: convert tcf_exts from list to pointer array")
we do dynamic allocation in tcf_exts_init(), therefore we need
to handle the ENOMEM case properly.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
c1346a7e70
commit
b9a24bb76b
@@ -138,10 +138,12 @@ static int basic_set_parms(struct net *net, struct tcf_proto *tp,
|
||||
struct tcf_exts e;
|
||||
struct tcf_ematch_tree t;
|
||||
|
||||
tcf_exts_init(&e, TCA_BASIC_ACT, TCA_BASIC_POLICE);
|
||||
err = tcf_exts_validate(net, tp, tb, est, &e, ovr);
|
||||
err = tcf_exts_init(&e, TCA_BASIC_ACT, TCA_BASIC_POLICE);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = tcf_exts_validate(net, tp, tb, est, &e, ovr);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
err = tcf_em_tree_validate(tp, tb[TCA_BASIC_EMATCHES], &t);
|
||||
if (err < 0)
|
||||
@@ -189,7 +191,10 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
|
||||
if (!fnew)
|
||||
return -ENOBUFS;
|
||||
|
||||
tcf_exts_init(&fnew->exts, TCA_BASIC_ACT, TCA_BASIC_POLICE);
|
||||
err = tcf_exts_init(&fnew->exts, TCA_BASIC_ACT, TCA_BASIC_POLICE);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
err = -EINVAL;
|
||||
if (handle) {
|
||||
fnew->handle = handle;
|
||||
@@ -226,6 +231,7 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
|
||||
|
||||
return 0;
|
||||
errout:
|
||||
tcf_exts_destroy(&fnew->exts);
|
||||
kfree(fnew);
|
||||
return err;
|
||||
}
|
||||
|
Reference in New Issue
Block a user