aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_route.c
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2016-08-19 15:36:54 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-22 20:02:31 -0400
commitb9a24bb76bf611a5268ceffe04219e6ad264559b (patch)
tree78aefca9f8e4da33abea28a0ff61fbc59fd2c66d /net/sched/cls_route.c
parentc1346a7e70b5be7f01cc1f64a7e3aefb80d48ad7 (diff)
net_sched: properly handle failure case of tcf_exts_init()
After commit 22dc13c837c3 ("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>
Diffstat (limited to 'net/sched/cls_route.c')
-rw-r--r--net/sched/cls_route.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
index 08a3b0a6f5ab..c91e65d81a48 100644
--- a/net/sched/cls_route.c
+++ b/net/sched/cls_route.c
@@ -383,17 +383,19 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
383 struct nlattr **tb, struct nlattr *est, int new, 383 struct nlattr **tb, struct nlattr *est, int new,
384 bool ovr) 384 bool ovr)
385{ 385{
386 int err;
387 u32 id = 0, to = 0, nhandle = 0x8000; 386 u32 id = 0, to = 0, nhandle = 0x8000;
388 struct route4_filter *fp; 387 struct route4_filter *fp;
389 unsigned int h1; 388 unsigned int h1;
390 struct route4_bucket *b; 389 struct route4_bucket *b;
391 struct tcf_exts e; 390 struct tcf_exts e;
391 int err;
392 392
393 tcf_exts_init(&e, TCA_ROUTE4_ACT, TCA_ROUTE4_POLICE); 393 err = tcf_exts_init(&e, TCA_ROUTE4_ACT, TCA_ROUTE4_POLICE);
394 err = tcf_exts_validate(net, tp, tb, est, &e, ovr);
395 if (err < 0) 394 if (err < 0)
396 return err; 395 return err;
396 err = tcf_exts_validate(net, tp, tb, est, &e, ovr);
397 if (err < 0)
398 goto errout;
397 399
398 err = -EINVAL; 400 err = -EINVAL;
399 if (tb[TCA_ROUTE4_TO]) { 401 if (tb[TCA_ROUTE4_TO]) {
@@ -503,7 +505,10 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
503 if (!f) 505 if (!f)
504 goto errout; 506 goto errout;
505 507
506 tcf_exts_init(&f->exts, TCA_ROUTE4_ACT, TCA_ROUTE4_POLICE); 508 err = tcf_exts_init(&f->exts, TCA_ROUTE4_ACT, TCA_ROUTE4_POLICE);
509 if (err < 0)
510 goto errout;
511
507 if (fold) { 512 if (fold) {
508 f->id = fold->id; 513 f->id = fold->id;
509 f->iif = fold->iif; 514 f->iif = fold->iif;
@@ -557,6 +562,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
557 return 0; 562 return 0;
558 563
559errout: 564errout:
565 tcf_exts_destroy(&f->exts);
560 kfree(f); 566 kfree(f);
561 return err; 567 return err;
562} 568}