diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-23 23:33:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:11:18 -0500 |
commit | cee63723b358e594225e812d6e14a2a0abfd5c88 (patch) | |
tree | 847f929e0f445cca8cdf55d7c17a56b0d0f2ec68 | |
parent | ab27cfb85c5778400740ad0c401bde65616774eb (diff) |
[NET_SCHED]: Propagate nla_parse return value
nla_parse() returns more detailed errno codes, propagate them back on
error.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/sched/act_api.c | 29 | ||||
-rw-r--r-- | net/sched/act_gact.c | 7 | ||||
-rw-r--r-- | net/sched/act_ipt.c | 6 | ||||
-rw-r--r-- | net/sched/act_mirred.c | 8 | ||||
-rw-r--r-- | net/sched/act_nat.c | 8 | ||||
-rw-r--r-- | net/sched/act_pedit.c | 8 | ||||
-rw-r--r-- | net/sched/act_police.c | 6 | ||||
-rw-r--r-- | net/sched/act_simple.c | 8 | ||||
-rw-r--r-- | net/sched/cls_basic.c | 7 | ||||
-rw-r--r-- | net/sched/cls_fw.c | 5 | ||||
-rw-r--r-- | net/sched/cls_route.c | 5 | ||||
-rw-r--r-- | net/sched/cls_rsvp.h | 5 | ||||
-rw-r--r-- | net/sched/cls_tcindex.c | 6 | ||||
-rw-r--r-- | net/sched/cls_u32.c | 5 | ||||
-rw-r--r-- | net/sched/em_meta.c | 6 | ||||
-rw-r--r-- | net/sched/ematch.c | 6 | ||||
-rw-r--r-- | net/sched/sch_atm.c | 6 | ||||
-rw-r--r-- | net/sched/sch_cbq.c | 14 | ||||
-rw-r--r-- | net/sched/sch_dsmark.c | 14 | ||||
-rw-r--r-- | net/sched/sch_gred.c | 16 | ||||
-rw-r--r-- | net/sched/sch_hfsc.c | 7 | ||||
-rw-r--r-- | net/sched/sch_htb.c | 23 | ||||
-rw-r--r-- | net/sched/sch_prio.c | 9 | ||||
-rw-r--r-- | net/sched/sch_red.c | 7 | ||||
-rw-r--r-- | net/sched/sch_tbf.c | 10 |
25 files changed, 171 insertions, 60 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index ea80f82dbb6a..87818d7fb623 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -473,17 +473,18 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est, | |||
473 | struct nlattr *kind; | 473 | struct nlattr *kind; |
474 | int err; | 474 | int err; |
475 | 475 | ||
476 | err = -EINVAL; | ||
477 | |||
478 | if (name == NULL) { | 476 | if (name == NULL) { |
479 | if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0) | 477 | err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL); |
478 | if (err < 0) | ||
480 | goto err_out; | 479 | goto err_out; |
480 | err = -EINVAL; | ||
481 | kind = tb[TCA_ACT_KIND]; | 481 | kind = tb[TCA_ACT_KIND]; |
482 | if (kind == NULL) | 482 | if (kind == NULL) |
483 | goto err_out; | 483 | goto err_out; |
484 | if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ) | 484 | if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ) |
485 | goto err_out; | 485 | goto err_out; |
486 | } else { | 486 | } else { |
487 | err = -EINVAL; | ||
487 | if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ) | 488 | if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ) |
488 | goto err_out; | 489 | goto err_out; |
489 | } | 490 | } |
@@ -548,10 +549,12 @@ struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est, | |||
548 | { | 549 | { |
549 | struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; | 550 | struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; |
550 | struct tc_action *head = NULL, *act, *act_prev = NULL; | 551 | struct tc_action *head = NULL, *act, *act_prev = NULL; |
552 | int err; | ||
551 | int i; | 553 | int i; |
552 | 554 | ||
553 | if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0) | 555 | err = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL); |
554 | return ERR_PTR(-EINVAL); | 556 | if (err < 0) |
557 | return ERR_PTR(err); | ||
555 | 558 | ||
556 | for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { | 559 | for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { |
557 | act = tcf_action_init_1(tb[i], est, name, ovr, bind); | 560 | act = tcf_action_init_1(tb[i], est, name, ovr, bind); |
@@ -674,10 +677,11 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | |||
674 | int index; | 677 | int index; |
675 | int err; | 678 | int err; |
676 | 679 | ||
677 | err = -EINVAL; | 680 | err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL); |
678 | if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0) | 681 | if (err < 0) |
679 | goto err_out; | 682 | goto err_out; |
680 | 683 | ||
684 | err = -EINVAL; | ||
681 | if (tb[TCA_ACT_INDEX] == NULL || | 685 | if (tb[TCA_ACT_INDEX] == NULL || |
682 | nla_len(tb[TCA_ACT_INDEX]) < sizeof(index)) | 686 | nla_len(tb[TCA_ACT_INDEX]) < sizeof(index)) |
683 | goto err_out; | 687 | goto err_out; |
@@ -759,9 +763,11 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | |||
759 | 763 | ||
760 | b = skb_tail_pointer(skb); | 764 | b = skb_tail_pointer(skb); |
761 | 765 | ||
762 | if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0) | 766 | err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL); |
767 | if (err < 0) | ||
763 | goto err_out; | 768 | goto err_out; |
764 | 769 | ||
770 | err = -EINVAL; | ||
765 | kind = tb[TCA_ACT_KIND]; | 771 | kind = tb[TCA_ACT_KIND]; |
766 | a->ops = tc_lookup_action(kind); | 772 | a->ops = tc_lookup_action(kind); |
767 | if (a->ops == NULL) | 773 | if (a->ops == NULL) |
@@ -804,12 +810,13 @@ err_out: | |||
804 | static int | 810 | static int |
805 | tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event) | 811 | tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event) |
806 | { | 812 | { |
807 | int i, ret = 0; | 813 | int i, ret; |
808 | struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; | 814 | struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; |
809 | struct tc_action *head = NULL, *act, *act_prev = NULL; | 815 | struct tc_action *head = NULL, *act, *act_prev = NULL; |
810 | 816 | ||
811 | if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0) | 817 | ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL); |
812 | return -EINVAL; | 818 | if (ret < 0) |
819 | return ret; | ||
813 | 820 | ||
814 | if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { | 821 | if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { |
815 | if (tb[0] != NULL && tb[1] == NULL) | 822 | if (tb[0] != NULL && tb[1] == NULL) |
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index 5402cf885f95..df214d47fc92 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c | |||
@@ -61,10 +61,15 @@ static int tcf_gact_init(struct nlattr *nla, struct nlattr *est, | |||
61 | struct tcf_gact *gact; | 61 | struct tcf_gact *gact; |
62 | struct tcf_common *pc; | 62 | struct tcf_common *pc; |
63 | int ret = 0; | 63 | int ret = 0; |
64 | int err; | ||
64 | 65 | ||
65 | if (nla == NULL || nla_parse_nested(tb, TCA_GACT_MAX, nla, NULL) < 0) | 66 | if (nla == NULL) |
66 | return -EINVAL; | 67 | return -EINVAL; |
67 | 68 | ||
69 | err = nla_parse_nested(tb, TCA_GACT_MAX, nla, NULL); | ||
70 | if (err < 0) | ||
71 | return err; | ||
72 | |||
68 | if (tb[TCA_GACT_PARMS] == NULL || | 73 | if (tb[TCA_GACT_PARMS] == NULL || |
69 | nla_len(tb[TCA_GACT_PARMS]) < sizeof(*parm)) | 74 | nla_len(tb[TCA_GACT_PARMS]) < sizeof(*parm)) |
70 | return -EINVAL; | 75 | return -EINVAL; |
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index fee5282637cc..12693347d56a 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c | |||
@@ -104,9 +104,13 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est, | |||
104 | u32 hook = 0; | 104 | u32 hook = 0; |
105 | u32 index = 0; | 105 | u32 index = 0; |
106 | 106 | ||
107 | if (nla == NULL || nla_parse_nested(tb, TCA_IPT_MAX, nla, NULL) < 0) | 107 | if (nla == NULL) |
108 | return -EINVAL; | 108 | return -EINVAL; |
109 | 109 | ||
110 | err = nla_parse_nested(tb, TCA_IPT_MAX, nla, NULL); | ||
111 | if (err < 0) | ||
112 | return err; | ||
113 | |||
110 | if (tb[TCA_IPT_HOOK] == NULL || | 114 | if (tb[TCA_IPT_HOOK] == NULL || |
111 | nla_len(tb[TCA_IPT_HOOK]) < sizeof(u32)) | 115 | nla_len(tb[TCA_IPT_HOOK]) < sizeof(u32)) |
112 | return -EINVAL; | 116 | return -EINVAL; |
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index db943a8c7388..6cb5e30dcf8c 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c | |||
@@ -62,12 +62,16 @@ static int tcf_mirred_init(struct nlattr *nla, struct nlattr *est, | |||
62 | struct tcf_mirred *m; | 62 | struct tcf_mirred *m; |
63 | struct tcf_common *pc; | 63 | struct tcf_common *pc; |
64 | struct net_device *dev = NULL; | 64 | struct net_device *dev = NULL; |
65 | int ret = 0; | 65 | int ret = 0, err; |
66 | int ok_push = 0; | 66 | int ok_push = 0; |
67 | 67 | ||
68 | if (nla == NULL || nla_parse_nested(tb, TCA_MIRRED_MAX, nla, NULL) < 0) | 68 | if (nla == NULL) |
69 | return -EINVAL; | 69 | return -EINVAL; |
70 | 70 | ||
71 | err = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, NULL); | ||
72 | if (err < 0) | ||
73 | return err; | ||
74 | |||
71 | if (tb[TCA_MIRRED_PARMS] == NULL || | 75 | if (tb[TCA_MIRRED_PARMS] == NULL || |
72 | nla_len(tb[TCA_MIRRED_PARMS]) < sizeof(*parm)) | 76 | nla_len(tb[TCA_MIRRED_PARMS]) < sizeof(*parm)) |
73 | return -EINVAL; | 77 | return -EINVAL; |
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index be007bb31b59..5a512d4dc37c 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c | |||
@@ -45,13 +45,17 @@ static int tcf_nat_init(struct nlattr *nla, struct nlattr *est, | |||
45 | { | 45 | { |
46 | struct nlattr *tb[TCA_NAT_MAX + 1]; | 46 | struct nlattr *tb[TCA_NAT_MAX + 1]; |
47 | struct tc_nat *parm; | 47 | struct tc_nat *parm; |
48 | int ret = 0; | 48 | int ret = 0, err; |
49 | struct tcf_nat *p; | 49 | struct tcf_nat *p; |
50 | struct tcf_common *pc; | 50 | struct tcf_common *pc; |
51 | 51 | ||
52 | if (nla == NULL || nla_parse_nested(tb, TCA_NAT_MAX, nla, NULL) < 0) | 52 | if (nla == NULL) |
53 | return -EINVAL; | 53 | return -EINVAL; |
54 | 54 | ||
55 | err = nla_parse_nested(tb, TCA_NAT_MAX, nla, NULL); | ||
56 | if (err < 0) | ||
57 | return err; | ||
58 | |||
55 | if (tb[TCA_NAT_PARMS] == NULL || | 59 | if (tb[TCA_NAT_PARMS] == NULL || |
56 | nla_len(tb[TCA_NAT_PARMS]) < sizeof(*parm)) | 60 | nla_len(tb[TCA_NAT_PARMS]) < sizeof(*parm)) |
57 | return -EINVAL; | 61 | return -EINVAL; |
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index 88d8a15a1921..1b9ca45a78e5 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c | |||
@@ -38,15 +38,19 @@ static int tcf_pedit_init(struct nlattr *nla, struct nlattr *est, | |||
38 | { | 38 | { |
39 | struct nlattr *tb[TCA_PEDIT_MAX + 1]; | 39 | struct nlattr *tb[TCA_PEDIT_MAX + 1]; |
40 | struct tc_pedit *parm; | 40 | struct tc_pedit *parm; |
41 | int ret = 0; | 41 | int ret = 0, err; |
42 | struct tcf_pedit *p; | 42 | struct tcf_pedit *p; |
43 | struct tcf_common *pc; | 43 | struct tcf_common *pc; |
44 | struct tc_pedit_key *keys = NULL; | 44 | struct tc_pedit_key *keys = NULL; |
45 | int ksize; | 45 | int ksize; |
46 | 46 | ||
47 | if (nla == NULL || nla_parse_nested(tb, TCA_PEDIT_MAX, nla, NULL) < 0) | 47 | if (nla == NULL) |
48 | return -EINVAL; | 48 | return -EINVAL; |
49 | 49 | ||
50 | err = nla_parse_nested(tb, TCA_PEDIT_MAX, nla, NULL); | ||
51 | if (err < 0) | ||
52 | return err; | ||
53 | |||
50 | if (tb[TCA_PEDIT_PARMS] == NULL || | 54 | if (tb[TCA_PEDIT_PARMS] == NULL || |
51 | nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm)) | 55 | nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm)) |
52 | return -EINVAL; | 56 | return -EINVAL; |
diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 3af5759aac26..c0fce9b98412 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c | |||
@@ -129,9 +129,13 @@ static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est, | |||
129 | struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; | 129 | struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; |
130 | int size; | 130 | int size; |
131 | 131 | ||
132 | if (nla == NULL || nla_parse_nested(tb, TCA_POLICE_MAX, nla, NULL) < 0) | 132 | if (nla == NULL) |
133 | return -EINVAL; | 133 | return -EINVAL; |
134 | 134 | ||
135 | err = nla_parse_nested(tb, TCA_POLICE_MAX, nla, NULL); | ||
136 | if (err < 0) | ||
137 | return err; | ||
138 | |||
135 | if (tb[TCA_POLICE_TBF] == NULL) | 139 | if (tb[TCA_POLICE_TBF] == NULL) |
136 | return -EINVAL; | 140 | return -EINVAL; |
137 | size = nla_len(tb[TCA_POLICE_TBF]); | 141 | size = nla_len(tb[TCA_POLICE_TBF]); |
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index d3226e24070b..cedaadf18eb2 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c | |||
@@ -93,11 +93,15 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, | |||
93 | struct tcf_common *pc; | 93 | struct tcf_common *pc; |
94 | void *defdata; | 94 | void *defdata; |
95 | u32 datalen = 0; | 95 | u32 datalen = 0; |
96 | int ret = 0; | 96 | int ret = 0, err; |
97 | 97 | ||
98 | if (nla == NULL || nla_parse_nested(tb, TCA_DEF_MAX, nla, NULL) < 0) | 98 | if (nla == NULL) |
99 | return -EINVAL; | 99 | return -EINVAL; |
100 | 100 | ||
101 | err = nla_parse_nested(tb, TCA_DEF_MAX, nla, NULL); | ||
102 | if (err < 0) | ||
103 | return err; | ||
104 | |||
101 | if (tb[TCA_DEF_PARMS] == NULL || | 105 | if (tb[TCA_DEF_PARMS] == NULL || |
102 | nla_len(tb[TCA_DEF_PARMS]) < sizeof(*parm)) | 106 | nla_len(tb[TCA_DEF_PARMS]) < sizeof(*parm)) |
103 | return -EINVAL; | 107 | return -EINVAL; |
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c index 3953da33956f..524b7885dc32 100644 --- a/net/sched/cls_basic.c +++ b/net/sched/cls_basic.c | |||
@@ -166,7 +166,7 @@ errout: | |||
166 | static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle, | 166 | static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle, |
167 | struct nlattr **tca, unsigned long *arg) | 167 | struct nlattr **tca, unsigned long *arg) |
168 | { | 168 | { |
169 | int err = -EINVAL; | 169 | int err; |
170 | struct basic_head *head = (struct basic_head *) tp->root; | 170 | struct basic_head *head = (struct basic_head *) tp->root; |
171 | struct nlattr *tb[TCA_BASIC_MAX + 1]; | 171 | struct nlattr *tb[TCA_BASIC_MAX + 1]; |
172 | struct basic_filter *f = (struct basic_filter *) *arg; | 172 | struct basic_filter *f = (struct basic_filter *) *arg; |
@@ -174,8 +174,9 @@ static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
174 | if (tca[TCA_OPTIONS] == NULL) | 174 | if (tca[TCA_OPTIONS] == NULL) |
175 | return -EINVAL; | 175 | return -EINVAL; |
176 | 176 | ||
177 | if (nla_parse_nested(tb, TCA_BASIC_MAX, tca[TCA_OPTIONS], NULL) < 0) | 177 | err = nla_parse_nested(tb, TCA_BASIC_MAX, tca[TCA_OPTIONS], NULL); |
178 | return -EINVAL; | 178 | if (err < 0) |
179 | return err; | ||
179 | 180 | ||
180 | if (f != NULL) { | 181 | if (f != NULL) { |
181 | if (handle && f->handle != handle) | 182 | if (handle && f->handle != handle) |
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index db6e90a37846..a1a9f4d26b8c 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c | |||
@@ -246,8 +246,9 @@ static int fw_change(struct tcf_proto *tp, unsigned long base, | |||
246 | if (!opt) | 246 | if (!opt) |
247 | return handle ? -EINVAL : 0; | 247 | return handle ? -EINVAL : 0; |
248 | 248 | ||
249 | if (nla_parse_nested(tb, TCA_FW_MAX, opt, NULL) < 0) | 249 | err = nla_parse_nested(tb, TCA_FW_MAX, opt, NULL); |
250 | return -EINVAL; | 250 | if (err < 0) |
251 | return err; | ||
251 | 252 | ||
252 | if (f != NULL) { | 253 | if (f != NULL) { |
253 | if (f->id != handle && handle) | 254 | if (f->id != handle && handle) |
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index b1aae84cbadc..3aa8109aa3ce 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c | |||
@@ -440,8 +440,9 @@ static int route4_change(struct tcf_proto *tp, unsigned long base, | |||
440 | if (opt == NULL) | 440 | if (opt == NULL) |
441 | return handle ? -EINVAL : 0; | 441 | return handle ? -EINVAL : 0; |
442 | 442 | ||
443 | if (nla_parse_nested(tb, TCA_ROUTE4_MAX, opt, NULL) < 0) | 443 | err = nla_parse_nested(tb, TCA_ROUTE4_MAX, opt, NULL); |
444 | return -EINVAL; | 444 | if (err < 0) |
445 | return err; | ||
445 | 446 | ||
446 | if ((f = (struct route4_filter*)*arg) != NULL) { | 447 | if ((f = (struct route4_filter*)*arg) != NULL) { |
447 | if (f->handle != handle && handle) | 448 | if (f->handle != handle && handle) |
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h index 2364c79d0837..5747408a7d4c 100644 --- a/net/sched/cls_rsvp.h +++ b/net/sched/cls_rsvp.h | |||
@@ -416,8 +416,9 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base, | |||
416 | if (opt == NULL) | 416 | if (opt == NULL) |
417 | return handle ? -EINVAL : 0; | 417 | return handle ? -EINVAL : 0; |
418 | 418 | ||
419 | if (nla_parse_nested(tb, TCA_RSVP_MAX, opt, NULL) < 0) | 419 | err = nla_parse_nested(tb, TCA_RSVP_MAX, opt, NULL); |
420 | return -EINVAL; | 420 | if (err < 0) |
421 | return err; | ||
421 | 422 | ||
422 | err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &rsvp_ext_map); | 423 | err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &rsvp_ext_map); |
423 | if (err < 0) | 424 | if (err < 0) |
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index ed8023944fe5..6b84d276e5ac 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c | |||
@@ -350,6 +350,7 @@ tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
350 | struct nlattr *tb[TCA_TCINDEX_MAX + 1]; | 350 | struct nlattr *tb[TCA_TCINDEX_MAX + 1]; |
351 | struct tcindex_data *p = PRIV(tp); | 351 | struct tcindex_data *p = PRIV(tp); |
352 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) *arg; | 352 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) *arg; |
353 | int err; | ||
353 | 354 | ||
354 | pr_debug("tcindex_change(tp %p,handle 0x%08x,tca %p,arg %p),opt %p," | 355 | pr_debug("tcindex_change(tp %p,handle 0x%08x,tca %p,arg %p),opt %p," |
355 | "p %p,r %p,*arg 0x%lx\n", | 356 | "p %p,r %p,*arg 0x%lx\n", |
@@ -358,8 +359,9 @@ tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
358 | if (!opt) | 359 | if (!opt) |
359 | return 0; | 360 | return 0; |
360 | 361 | ||
361 | if (nla_parse_nested(tb, TCA_TCINDEX_MAX, opt, NULL) < 0) | 362 | err = nla_parse_nested(tb, TCA_TCINDEX_MAX, opt, NULL); |
362 | return -EINVAL; | 363 | if (err < 0) |
364 | return err; | ||
363 | 365 | ||
364 | return tcindex_set_parms(tp, base, handle, p, r, tb, tca[TCA_RATE]); | 366 | return tcindex_set_parms(tp, base, handle, p, r, tb, tca[TCA_RATE]); |
365 | } | 367 | } |
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index aaf5049f951c..3228cc4ae082 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -531,8 +531,9 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
531 | if (opt == NULL) | 531 | if (opt == NULL) |
532 | return handle ? -EINVAL : 0; | 532 | return handle ? -EINVAL : 0; |
533 | 533 | ||
534 | if (nla_parse_nested(tb, TCA_U32_MAX, opt, NULL) < 0) | 534 | err = nla_parse_nested(tb, TCA_U32_MAX, opt, NULL); |
535 | return -EINVAL; | 535 | if (err < 0) |
536 | return err; | ||
536 | 537 | ||
537 | if ((n = (struct tc_u_knode*)*arg) != NULL) { | 538 | if ((n = (struct tc_u_knode*)*arg) != NULL) { |
538 | if (TC_U32_KEY(n->handle) == 0) | 539 | if (TC_U32_KEY(n->handle) == 0) |
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index 92b6863e928d..dd5723670d31 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c | |||
@@ -749,14 +749,16 @@ static inline int meta_is_supported(struct meta_value *val) | |||
749 | static int em_meta_change(struct tcf_proto *tp, void *data, int len, | 749 | static int em_meta_change(struct tcf_proto *tp, void *data, int len, |
750 | struct tcf_ematch *m) | 750 | struct tcf_ematch *m) |
751 | { | 751 | { |
752 | int err = -EINVAL; | 752 | int err; |
753 | struct nlattr *tb[TCA_EM_META_MAX + 1]; | 753 | struct nlattr *tb[TCA_EM_META_MAX + 1]; |
754 | struct tcf_meta_hdr *hdr; | 754 | struct tcf_meta_hdr *hdr; |
755 | struct meta_match *meta = NULL; | 755 | struct meta_match *meta = NULL; |
756 | 756 | ||
757 | if (nla_parse(tb, TCA_EM_META_MAX, data, len, NULL) < 0) | 757 | err = nla_parse(tb, TCA_EM_META_MAX, data, len, NULL); |
758 | if (err < 0) | ||
758 | goto errout; | 759 | goto errout; |
759 | 760 | ||
761 | err = -EINVAL; | ||
760 | if (tb[TCA_EM_META_HDR] == NULL || | 762 | if (tb[TCA_EM_META_HDR] == NULL || |
761 | nla_len(tb[TCA_EM_META_HDR]) < sizeof(*hdr)) | 763 | nla_len(tb[TCA_EM_META_HDR]) < sizeof(*hdr)) |
762 | goto errout; | 764 | goto errout; |
diff --git a/net/sched/ematch.c b/net/sched/ematch.c index 72d9b2735245..d2b480f01a40 100644 --- a/net/sched/ematch.c +++ b/net/sched/ematch.c | |||
@@ -301,7 +301,7 @@ errout: | |||
301 | int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, | 301 | int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, |
302 | struct tcf_ematch_tree *tree) | 302 | struct tcf_ematch_tree *tree) |
303 | { | 303 | { |
304 | int idx, list_len, matches_len, err = -EINVAL; | 304 | int idx, list_len, matches_len, err; |
305 | struct nlattr *tb[TCA_EMATCH_TREE_MAX + 1]; | 305 | struct nlattr *tb[TCA_EMATCH_TREE_MAX + 1]; |
306 | struct nlattr *rt_match, *rt_hdr, *rt_list; | 306 | struct nlattr *rt_match, *rt_hdr, *rt_list; |
307 | struct tcf_ematch_tree_hdr *tree_hdr; | 307 | struct tcf_ematch_tree_hdr *tree_hdr; |
@@ -312,9 +312,11 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, | |||
312 | return 0; | 312 | return 0; |
313 | } | 313 | } |
314 | 314 | ||
315 | if (nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL) < 0) | 315 | err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL); |
316 | if (err < 0) | ||
316 | goto errout; | 317 | goto errout; |
317 | 318 | ||
319 | err = -EINVAL; | ||
318 | rt_hdr = tb[TCA_EMATCH_TREE_HDR]; | 320 | rt_hdr = tb[TCA_EMATCH_TREE_HDR]; |
319 | rt_list = tb[TCA_EMATCH_TREE_LIST]; | 321 | rt_list = tb[TCA_EMATCH_TREE_LIST]; |
320 | 322 | ||
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index e58739153782..aaa32a22726d 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c | |||
@@ -223,8 +223,12 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, | |||
223 | */ | 223 | */ |
224 | if (flow) | 224 | if (flow) |
225 | return -EBUSY; | 225 | return -EBUSY; |
226 | if (opt == NULL || nla_parse_nested(tb, TCA_ATM_MAX, opt, NULL)) | 226 | if (opt == NULL) |
227 | return -EINVAL; | 227 | return -EINVAL; |
228 | error = nla_parse_nested(tb, TCA_ATM_MAX, opt, NULL); | ||
229 | if (error < 0) | ||
230 | return error; | ||
231 | |||
228 | if (!tb[TCA_ATM_FD] || nla_len(tb[TCA_ATM_FD]) < sizeof(fd)) | 232 | if (!tb[TCA_ATM_FD] || nla_len(tb[TCA_ATM_FD]) < sizeof(fd)) |
229 | return -EINVAL; | 233 | return -EINVAL; |
230 | fd = *(int *)nla_data(tb[TCA_ATM_FD]); | 234 | fd = *(int *)nla_data(tb[TCA_ATM_FD]); |
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 5c8667ef4ba7..585f8a6ec7ec 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c | |||
@@ -1382,9 +1382,13 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt) | |||
1382 | struct cbq_sched_data *q = qdisc_priv(sch); | 1382 | struct cbq_sched_data *q = qdisc_priv(sch); |
1383 | struct nlattr *tb[TCA_CBQ_MAX + 1]; | 1383 | struct nlattr *tb[TCA_CBQ_MAX + 1]; |
1384 | struct tc_ratespec *r; | 1384 | struct tc_ratespec *r; |
1385 | int err; | ||
1386 | |||
1387 | err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL); | ||
1388 | if (err < 0) | ||
1389 | return err; | ||
1385 | 1390 | ||
1386 | if (nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL) < 0 || | 1391 | if (tb[TCA_CBQ_RTAB] == NULL || tb[TCA_CBQ_RATE] == NULL || |
1387 | tb[TCA_CBQ_RTAB] == NULL || tb[TCA_CBQ_RATE] == NULL || | ||
1388 | nla_len(tb[TCA_CBQ_RATE]) < sizeof(struct tc_ratespec)) | 1392 | nla_len(tb[TCA_CBQ_RATE]) < sizeof(struct tc_ratespec)) |
1389 | return -EINVAL; | 1393 | return -EINVAL; |
1390 | 1394 | ||
@@ -1764,9 +1768,13 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t | |||
1764 | struct cbq_class *parent; | 1768 | struct cbq_class *parent; |
1765 | struct qdisc_rate_table *rtab = NULL; | 1769 | struct qdisc_rate_table *rtab = NULL; |
1766 | 1770 | ||
1767 | if (opt==NULL || nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL)) | 1771 | if (opt == NULL) |
1768 | return -EINVAL; | 1772 | return -EINVAL; |
1769 | 1773 | ||
1774 | err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL); | ||
1775 | if (err < 0) | ||
1776 | return err; | ||
1777 | |||
1770 | if (tb[TCA_CBQ_OVL_STRATEGY] && | 1778 | if (tb[TCA_CBQ_OVL_STRATEGY] && |
1771 | nla_len(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(struct tc_cbq_ovl)) | 1779 | nla_len(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(struct tc_cbq_ovl)) |
1772 | return -EINVAL; | 1780 | return -EINVAL; |
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index f183ab768873..f1d0a08aca75 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c | |||
@@ -116,9 +116,14 @@ static int dsmark_change(struct Qdisc *sch, u32 classid, u32 parent, | |||
116 | goto errout; | 116 | goto errout; |
117 | } | 117 | } |
118 | 118 | ||
119 | if (!opt || nla_parse_nested(tb, TCA_DSMARK_MAX, opt, NULL)) | 119 | if (!opt) |
120 | goto errout; | 120 | goto errout; |
121 | 121 | ||
122 | err = nla_parse_nested(tb, TCA_DSMARK_MAX, opt, NULL); | ||
123 | if (err < 0) | ||
124 | return err; | ||
125 | |||
126 | err = -EINVAL; | ||
122 | if (tb[TCA_DSMARK_MASK]) { | 127 | if (tb[TCA_DSMARK_MASK]) { |
123 | if (nla_len(tb[TCA_DSMARK_MASK]) < sizeof(u8)) | 128 | if (nla_len(tb[TCA_DSMARK_MASK]) < sizeof(u8)) |
124 | goto errout; | 129 | goto errout; |
@@ -351,9 +356,14 @@ static int dsmark_init(struct Qdisc *sch, struct nlattr *opt) | |||
351 | 356 | ||
352 | pr_debug("dsmark_init(sch %p,[qdisc %p],opt %p)\n", sch, p, opt); | 357 | pr_debug("dsmark_init(sch %p,[qdisc %p],opt %p)\n", sch, p, opt); |
353 | 358 | ||
354 | if (!opt || nla_parse_nested(tb, TCA_DSMARK_MAX, opt, NULL) < 0) | 359 | if (!opt) |
360 | goto errout; | ||
361 | |||
362 | err = nla_parse_nested(tb, TCA_DSMARK_MAX, opt, NULL); | ||
363 | if (err < 0) | ||
355 | goto errout; | 364 | goto errout; |
356 | 365 | ||
366 | err = -EINVAL; | ||
357 | if (nla_len(tb[TCA_DSMARK_INDICES]) < sizeof(u16)) | 367 | if (nla_len(tb[TCA_DSMARK_INDICES]) < sizeof(u16)) |
358 | goto errout; | 368 | goto errout; |
359 | indices = nla_get_u16(tb[TCA_DSMARK_INDICES]); | 369 | indices = nla_get_u16(tb[TCA_DSMARK_INDICES]); |
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c index 6b784838a534..365c7d8b17ab 100644 --- a/net/sched/sch_gred.c +++ b/net/sched/sch_gred.c | |||
@@ -430,12 +430,16 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt) | |||
430 | struct gred_sched *table = qdisc_priv(sch); | 430 | struct gred_sched *table = qdisc_priv(sch); |
431 | struct tc_gred_qopt *ctl; | 431 | struct tc_gred_qopt *ctl; |
432 | struct nlattr *tb[TCA_GRED_MAX + 1]; | 432 | struct nlattr *tb[TCA_GRED_MAX + 1]; |
433 | int err = -EINVAL, prio = GRED_DEF_PRIO; | 433 | int err, prio = GRED_DEF_PRIO; |
434 | u8 *stab; | 434 | u8 *stab; |
435 | 435 | ||
436 | if (opt == NULL || nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL)) | 436 | if (opt == NULL) |
437 | return -EINVAL; | 437 | return -EINVAL; |
438 | 438 | ||
439 | err = nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL); | ||
440 | if (err < 0) | ||
441 | return err; | ||
442 | |||
439 | if (tb[TCA_GRED_PARMS] == NULL && tb[TCA_GRED_STAB] == NULL) | 443 | if (tb[TCA_GRED_PARMS] == NULL && tb[TCA_GRED_STAB] == NULL) |
440 | return gred_change_table_def(sch, opt); | 444 | return gred_change_table_def(sch, opt); |
441 | 445 | ||
@@ -445,6 +449,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt) | |||
445 | nla_len(tb[TCA_GRED_STAB]) < 256) | 449 | nla_len(tb[TCA_GRED_STAB]) < 256) |
446 | return -EINVAL; | 450 | return -EINVAL; |
447 | 451 | ||
452 | err = -EINVAL; | ||
448 | ctl = nla_data(tb[TCA_GRED_PARMS]); | 453 | ctl = nla_data(tb[TCA_GRED_PARMS]); |
449 | stab = nla_data(tb[TCA_GRED_STAB]); | 454 | stab = nla_data(tb[TCA_GRED_STAB]); |
450 | 455 | ||
@@ -489,10 +494,15 @@ errout: | |||
489 | static int gred_init(struct Qdisc *sch, struct nlattr *opt) | 494 | static int gred_init(struct Qdisc *sch, struct nlattr *opt) |
490 | { | 495 | { |
491 | struct nlattr *tb[TCA_GRED_MAX + 1]; | 496 | struct nlattr *tb[TCA_GRED_MAX + 1]; |
497 | int err; | ||
492 | 498 | ||
493 | if (opt == NULL || nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL)) | 499 | if (opt == NULL) |
494 | return -EINVAL; | 500 | return -EINVAL; |
495 | 501 | ||
502 | err = nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL); | ||
503 | if (err < 0) | ||
504 | return err; | ||
505 | |||
496 | if (tb[TCA_GRED_PARMS] || tb[TCA_GRED_STAB]) | 506 | if (tb[TCA_GRED_PARMS] || tb[TCA_GRED_STAB]) |
497 | return -EINVAL; | 507 | return -EINVAL; |
498 | 508 | ||
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 4e6a164d3058..fcb4826158d6 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c | |||
@@ -997,10 +997,15 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, | |||
997 | struct nlattr *tb[TCA_HFSC_MAX + 1]; | 997 | struct nlattr *tb[TCA_HFSC_MAX + 1]; |
998 | struct tc_service_curve *rsc = NULL, *fsc = NULL, *usc = NULL; | 998 | struct tc_service_curve *rsc = NULL, *fsc = NULL, *usc = NULL; |
999 | u64 cur_time; | 999 | u64 cur_time; |
1000 | int err; | ||
1000 | 1001 | ||
1001 | if (opt == NULL || nla_parse_nested(tb, TCA_HFSC_MAX, opt, NULL)) | 1002 | if (opt == NULL) |
1002 | return -EINVAL; | 1003 | return -EINVAL; |
1003 | 1004 | ||
1005 | err = nla_parse_nested(tb, TCA_HFSC_MAX, opt, NULL); | ||
1006 | if (err < 0) | ||
1007 | return err; | ||
1008 | |||
1004 | if (tb[TCA_HFSC_RSC]) { | 1009 | if (tb[TCA_HFSC_RSC]) { |
1005 | if (nla_len(tb[TCA_HFSC_RSC]) < sizeof(*rsc)) | 1010 | if (nla_len(tb[TCA_HFSC_RSC]) < sizeof(*rsc)) |
1006 | return -EINVAL; | 1011 | return -EINVAL; |
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 3b3ff641b6d7..512df9a0a242 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -997,9 +997,17 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt) | |||
997 | struct htb_sched *q = qdisc_priv(sch); | 997 | struct htb_sched *q = qdisc_priv(sch); |
998 | struct nlattr *tb[TCA_HTB_INIT + 1]; | 998 | struct nlattr *tb[TCA_HTB_INIT + 1]; |
999 | struct tc_htb_glob *gopt; | 999 | struct tc_htb_glob *gopt; |
1000 | int err; | ||
1000 | int i; | 1001 | int i; |
1001 | if (!opt || nla_parse_nested(tb, TCA_HTB_INIT, opt, NULL) || | 1002 | |
1002 | tb[TCA_HTB_INIT] == NULL || | 1003 | if (!opt) |
1004 | return -EINVAL; | ||
1005 | |||
1006 | err = nla_parse_nested(tb, TCA_HTB_INIT, opt, NULL); | ||
1007 | if (err < 0) | ||
1008 | return err; | ||
1009 | |||
1010 | if (tb[TCA_HTB_INIT] == NULL || | ||
1003 | nla_len(tb[TCA_HTB_INIT]) < sizeof(*gopt)) { | 1011 | nla_len(tb[TCA_HTB_INIT]) < sizeof(*gopt)) { |
1004 | printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n"); | 1012 | printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n"); |
1005 | return -EINVAL; | 1013 | return -EINVAL; |
@@ -1302,8 +1310,15 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1302 | struct tc_htb_opt *hopt; | 1310 | struct tc_htb_opt *hopt; |
1303 | 1311 | ||
1304 | /* extract all subattrs from opt attr */ | 1312 | /* extract all subattrs from opt attr */ |
1305 | if (!opt || nla_parse_nested(tb, TCA_HTB_RTAB, opt, NULL) || | 1313 | if (!opt) |
1306 | tb[TCA_HTB_PARMS] == NULL || | 1314 | goto failure; |
1315 | |||
1316 | err = nla_parse_nested(tb, TCA_HTB_RTAB, opt, NULL); | ||
1317 | if (err < 0) | ||
1318 | goto failure; | ||
1319 | |||
1320 | err = -EINVAL; | ||
1321 | if (tb[TCA_HTB_PARMS] == NULL || | ||
1307 | nla_len(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) | 1322 | nla_len(tb[TCA_HTB_PARMS]) < sizeof(*hopt)) |
1308 | goto failure; | 1323 | goto failure; |
1309 | 1324 | ||
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index a4f932df86e9..4aa2b45dad0a 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c | |||
@@ -229,11 +229,14 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt) | |||
229 | struct prio_sched_data *q = qdisc_priv(sch); | 229 | struct prio_sched_data *q = qdisc_priv(sch); |
230 | struct tc_prio_qopt *qopt; | 230 | struct tc_prio_qopt *qopt; |
231 | struct nlattr *tb[TCA_PRIO_MAX + 1]; | 231 | struct nlattr *tb[TCA_PRIO_MAX + 1]; |
232 | int err; | ||
232 | int i; | 233 | int i; |
233 | 234 | ||
234 | if (nla_parse_nested_compat(tb, TCA_PRIO_MAX, opt, NULL, qopt, | 235 | err = nla_parse_nested_compat(tb, TCA_PRIO_MAX, opt, NULL, qopt, |
235 | sizeof(*qopt))) | 236 | sizeof(*qopt)); |
236 | return -EINVAL; | 237 | if (err < 0) |
238 | return err; | ||
239 | |||
237 | q->bands = qopt->bands; | 240 | q->bands = qopt->bands; |
238 | /* If we're multiqueue, make sure the number of incoming bands | 241 | /* If we're multiqueue, make sure the number of incoming bands |
239 | * matches the number of queues on the device we're associating with. | 242 | * matches the number of queues on the device we're associating with. |
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index 6ce8da5aca0b..dcf6afc196f8 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c | |||
@@ -207,10 +207,15 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt) | |||
207 | struct nlattr *tb[TCA_RED_MAX + 1]; | 207 | struct nlattr *tb[TCA_RED_MAX + 1]; |
208 | struct tc_red_qopt *ctl; | 208 | struct tc_red_qopt *ctl; |
209 | struct Qdisc *child = NULL; | 209 | struct Qdisc *child = NULL; |
210 | int err; | ||
210 | 211 | ||
211 | if (opt == NULL || nla_parse_nested(tb, TCA_RED_MAX, opt, NULL)) | 212 | if (opt == NULL) |
212 | return -EINVAL; | 213 | return -EINVAL; |
213 | 214 | ||
215 | err = nla_parse_nested(tb, TCA_RED_MAX, opt, NULL); | ||
216 | if (err < 0) | ||
217 | return err; | ||
218 | |||
214 | if (tb[TCA_RED_PARMS] == NULL || | 219 | if (tb[TCA_RED_PARMS] == NULL || |
215 | nla_len(tb[TCA_RED_PARMS]) < sizeof(*ctl) || | 220 | nla_len(tb[TCA_RED_PARMS]) < sizeof(*ctl) || |
216 | tb[TCA_RED_STAB] == NULL || | 221 | tb[TCA_RED_STAB] == NULL || |
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 6c4ad7e677b3..f9b1543e3d76 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c | |||
@@ -272,7 +272,7 @@ static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit) | |||
272 | 272 | ||
273 | static int tbf_change(struct Qdisc* sch, struct nlattr *opt) | 273 | static int tbf_change(struct Qdisc* sch, struct nlattr *opt) |
274 | { | 274 | { |
275 | int err = -EINVAL; | 275 | int err; |
276 | struct tbf_sched_data *q = qdisc_priv(sch); | 276 | struct tbf_sched_data *q = qdisc_priv(sch); |
277 | struct nlattr *tb[TCA_TBF_PTAB + 1]; | 277 | struct nlattr *tb[TCA_TBF_PTAB + 1]; |
278 | struct tc_tbf_qopt *qopt; | 278 | struct tc_tbf_qopt *qopt; |
@@ -281,8 +281,12 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt) | |||
281 | struct Qdisc *child = NULL; | 281 | struct Qdisc *child = NULL; |
282 | int max_size,n; | 282 | int max_size,n; |
283 | 283 | ||
284 | if (nla_parse_nested(tb, TCA_TBF_PTAB, opt, NULL) || | 284 | err = nla_parse_nested(tb, TCA_TBF_PTAB, opt, NULL); |
285 | tb[TCA_TBF_PARMS] == NULL || | 285 | if (err < 0) |
286 | return err; | ||
287 | |||
288 | err = -EINVAL; | ||
289 | if (tb[TCA_TBF_PARMS] == NULL || | ||
286 | nla_len(tb[TCA_TBF_PARMS]) < sizeof(*qopt)) | 290 | nla_len(tb[TCA_TBF_PARMS]) < sizeof(*qopt)) |
287 | goto done; | 291 | goto done; |
288 | 292 | ||