]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[NET_SCHED]: Propagate nla_parse return value
authorPatrick McHardy <kaber@trash.net>
Thu, 24 Jan 2008 04:33:32 +0000 (20:33 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:11:18 +0000 (15:11 -0800)
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>
25 files changed:
net/sched/act_api.c
net/sched/act_gact.c
net/sched/act_ipt.c
net/sched/act_mirred.c
net/sched/act_nat.c
net/sched/act_pedit.c
net/sched/act_police.c
net/sched/act_simple.c
net/sched/cls_basic.c
net/sched/cls_fw.c
net/sched/cls_route.c
net/sched/cls_rsvp.h
net/sched/cls_tcindex.c
net/sched/cls_u32.c
net/sched/em_meta.c
net/sched/ematch.c
net/sched/sch_atm.c
net/sched/sch_cbq.c
net/sched/sch_dsmark.c
net/sched/sch_gred.c
net/sched/sch_hfsc.c
net/sched/sch_htb.c
net/sched/sch_prio.c
net/sched/sch_red.c
net/sched/sch_tbf.c

index ea80f82dbb6a5c4b2e21fdc07ee42e1fcd645a9f..87818d7fb62398cc9bd5b542c54d937911cd77b1 100644 (file)
@@ -473,17 +473,18 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
        struct nlattr *kind;
        int err;
 
-       err = -EINVAL;
-
        if (name == NULL) {
-               if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
+               err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
+               if (err < 0)
                        goto err_out;
+               err = -EINVAL;
                kind = tb[TCA_ACT_KIND];
                if (kind == NULL)
                        goto err_out;
                if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ)
                        goto err_out;
        } else {
+               err = -EINVAL;
                if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ)
                        goto err_out;
        }
@@ -548,10 +549,12 @@ struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est,
 {
        struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
        struct tc_action *head = NULL, *act, *act_prev = NULL;
+       int err;
        int i;
 
-       if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0)
-               return ERR_PTR(-EINVAL);
+       err = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
+       if (err < 0)
+               return ERR_PTR(err);
 
        for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
                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)
        int index;
        int err;
 
-       err = -EINVAL;
-       if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
+       err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
+       if (err < 0)
                goto err_out;
 
+       err = -EINVAL;
        if (tb[TCA_ACT_INDEX] == NULL ||
            nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
                goto err_out;
@@ -759,9 +763,11 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
 
        b = skb_tail_pointer(skb);
 
-       if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
+       err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
+       if (err < 0)
                goto err_out;
 
+       err = -EINVAL;
        kind = tb[TCA_ACT_KIND];
        a->ops = tc_lookup_action(kind);
        if (a->ops == NULL)
@@ -804,12 +810,13 @@ err_out:
 static int
 tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event)
 {
-       int i, ret = 0;
+       int i, ret;
        struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
        struct tc_action *head = NULL, *act, *act_prev = NULL;
 
-       if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0)
-               return -EINVAL;
+       ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
+       if (ret < 0)
+               return ret;
 
        if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) {
                if (tb[0] != NULL && tb[1] == NULL)
index 5402cf885f9515b034e3d5376bf08ad58dd2f66c..df214d47fc922ad4cc5bbce98f1e2d8a941ffb67 100644 (file)
@@ -61,10 +61,15 @@ static int tcf_gact_init(struct nlattr *nla, struct nlattr *est,
        struct tcf_gact *gact;
        struct tcf_common *pc;
        int ret = 0;
+       int err;
 
-       if (nla == NULL || nla_parse_nested(tb, TCA_GACT_MAX, nla, NULL) < 0)
+       if (nla == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_GACT_MAX, nla, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_GACT_PARMS] == NULL ||
            nla_len(tb[TCA_GACT_PARMS]) < sizeof(*parm))
                return -EINVAL;
index fee5282637cc0b3913d04364a9f7ffe00f34d242..12693347d56a871c85ac019d95c6cbd821dd0464 100644 (file)
@@ -104,9 +104,13 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
        u32 hook = 0;
        u32 index = 0;
 
-       if (nla == NULL || nla_parse_nested(tb, TCA_IPT_MAX, nla, NULL) < 0)
+       if (nla == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_IPT_MAX, nla, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_IPT_HOOK] == NULL ||
            nla_len(tb[TCA_IPT_HOOK]) < sizeof(u32))
                return -EINVAL;
index db943a8c738847510e41fbe4f55c5f0bdd8f12eb..6cb5e30dcf8c726e914d52ca28f9399b60f80713 100644 (file)
@@ -62,12 +62,16 @@ static int tcf_mirred_init(struct nlattr *nla, struct nlattr *est,
        struct tcf_mirred *m;
        struct tcf_common *pc;
        struct net_device *dev = NULL;
-       int ret = 0;
+       int ret = 0, err;
        int ok_push = 0;
 
-       if (nla == NULL || nla_parse_nested(tb, TCA_MIRRED_MAX, nla, NULL) < 0)
+       if (nla == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_MIRRED_PARMS] == NULL ||
            nla_len(tb[TCA_MIRRED_PARMS]) < sizeof(*parm))
                return -EINVAL;
index be007bb31b59be92c09388eca2de1910e2ebb025..5a512d4dc37c9012fef2f866efbd77ee783cfbf5 100644 (file)
@@ -45,13 +45,17 @@ static int tcf_nat_init(struct nlattr *nla, struct nlattr *est,
 {
        struct nlattr *tb[TCA_NAT_MAX + 1];
        struct tc_nat *parm;
-       int ret = 0;
+       int ret = 0, err;
        struct tcf_nat *p;
        struct tcf_common *pc;
 
-       if (nla == NULL || nla_parse_nested(tb, TCA_NAT_MAX, nla, NULL) < 0)
+       if (nla == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_NAT_MAX, nla, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_NAT_PARMS] == NULL ||
            nla_len(tb[TCA_NAT_PARMS]) < sizeof(*parm))
                return -EINVAL;
index 88d8a15a19210edf4c3104216c92ad6a78bb1366..1b9ca45a78e54a5d16ed0c91505d258766c7c1ce 100644 (file)
@@ -38,15 +38,19 @@ static int tcf_pedit_init(struct nlattr *nla, struct nlattr *est,
 {
        struct nlattr *tb[TCA_PEDIT_MAX + 1];
        struct tc_pedit *parm;
-       int ret = 0;
+       int ret = 0, err;
        struct tcf_pedit *p;
        struct tcf_common *pc;
        struct tc_pedit_key *keys = NULL;
        int ksize;
 
-       if (nla == NULL || nla_parse_nested(tb, TCA_PEDIT_MAX, nla, NULL) < 0)
+       if (nla == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_PEDIT_MAX, nla, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_PEDIT_PARMS] == NULL ||
            nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm))
                return -EINVAL;
index 3af5759aac26a569bd0b6456be083aa4008c6037..c0fce9b984125acc0663dd66c947ddfae2bd818e 100644 (file)
@@ -129,9 +129,13 @@ static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est,
        struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
        int size;
 
-       if (nla == NULL || nla_parse_nested(tb, TCA_POLICE_MAX, nla, NULL) < 0)
+       if (nla == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_POLICE_MAX, nla, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_POLICE_TBF] == NULL)
                return -EINVAL;
        size = nla_len(tb[TCA_POLICE_TBF]);
index d3226e24070b408ed953a6652a92377c328f2583..cedaadf18eb2537bc460049313789fdcec157c7d 100644 (file)
@@ -93,11 +93,15 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
        struct tcf_common *pc;
        void *defdata;
        u32 datalen = 0;
-       int ret = 0;
+       int ret = 0, err;
 
-       if (nla == NULL || nla_parse_nested(tb, TCA_DEF_MAX, nla, NULL) < 0)
+       if (nla == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_DEF_MAX, nla, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_DEF_PARMS] == NULL ||
            nla_len(tb[TCA_DEF_PARMS]) < sizeof(*parm))
                return -EINVAL;
index 3953da33956f2a870b5bb2fbf2dd3cb6debeea27..524b7885dc32bc77aa9e52da943efd6c2007ae92 100644 (file)
@@ -166,7 +166,7 @@ errout:
 static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle,
                        struct nlattr **tca, unsigned long *arg)
 {
-       int err = -EINVAL;
+       int err;
        struct basic_head *head = (struct basic_head *) tp->root;
        struct nlattr *tb[TCA_BASIC_MAX + 1];
        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,
        if (tca[TCA_OPTIONS] == NULL)
                return -EINVAL;
 
-       if (nla_parse_nested(tb, TCA_BASIC_MAX, tca[TCA_OPTIONS], NULL) < 0)
-               return -EINVAL;
+       err = nla_parse_nested(tb, TCA_BASIC_MAX, tca[TCA_OPTIONS], NULL);
+       if (err < 0)
+               return err;
 
        if (f != NULL) {
                if (handle && f->handle != handle)
index db6e90a37846be85dc208d4ffb893a3821a48339..a1a9f4d26b8c3d283e7e93567262c06695911137 100644 (file)
@@ -246,8 +246,9 @@ static int fw_change(struct tcf_proto *tp, unsigned long base,
        if (!opt)
                return handle ? -EINVAL : 0;
 
-       if (nla_parse_nested(tb, TCA_FW_MAX, opt, NULL) < 0)
-               return -EINVAL;
+       err = nla_parse_nested(tb, TCA_FW_MAX, opt, NULL);
+       if (err < 0)
+               return err;
 
        if (f != NULL) {
                if (f->id != handle && handle)
index b1aae84cbadc9baf82e0bb3190d6d4509da255ad..3aa8109aa3ce67c4c67869f065e97da20d1c7116 100644 (file)
@@ -440,8 +440,9 @@ static int route4_change(struct tcf_proto *tp, unsigned long base,
        if (opt == NULL)
                return handle ? -EINVAL : 0;
 
-       if (nla_parse_nested(tb, TCA_ROUTE4_MAX, opt, NULL) < 0)
-               return -EINVAL;
+       err = nla_parse_nested(tb, TCA_ROUTE4_MAX, opt, NULL);
+       if (err < 0)
+               return err;
 
        if ((f = (struct route4_filter*)*arg) != NULL) {
                if (f->handle != handle && handle)
index 2364c79d083774ea5a08838a2ac4483d85859b29..5747408a7d4cfbd45f5d454f6f9fd0003c148a5f 100644 (file)
@@ -416,8 +416,9 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base,
        if (opt == NULL)
                return handle ? -EINVAL : 0;
 
-       if (nla_parse_nested(tb, TCA_RSVP_MAX, opt, NULL) < 0)
-               return -EINVAL;
+       err = nla_parse_nested(tb, TCA_RSVP_MAX, opt, NULL);
+       if (err < 0)
+               return err;
 
        err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &rsvp_ext_map);
        if (err < 0)
index ed8023944fe5cde94e0583f1de2f9520de127b42..6b84d276e5ac9fe2ebf3c9523332b41fa7ec1a67 100644 (file)
@@ -350,6 +350,7 @@ tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle,
        struct nlattr *tb[TCA_TCINDEX_MAX + 1];
        struct tcindex_data *p = PRIV(tp);
        struct tcindex_filter_result *r = (struct tcindex_filter_result *) *arg;
+       int err;
 
        pr_debug("tcindex_change(tp %p,handle 0x%08x,tca %p,arg %p),opt %p,"
            "p %p,r %p,*arg 0x%lx\n",
@@ -358,8 +359,9 @@ tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle,
        if (!opt)
                return 0;
 
-       if (nla_parse_nested(tb, TCA_TCINDEX_MAX, opt, NULL) < 0)
-               return -EINVAL;
+       err = nla_parse_nested(tb, TCA_TCINDEX_MAX, opt, NULL);
+       if (err < 0)
+               return err;
 
        return tcindex_set_parms(tp, base, handle, p, r, tb, tca[TCA_RATE]);
 }
index aaf5049f951cb4a750b27e94b18c00295056e0a1..3228cc4ae0821dabe24e5520bad6a509da8f7f7b 100644 (file)
@@ -531,8 +531,9 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
        if (opt == NULL)
                return handle ? -EINVAL : 0;
 
-       if (nla_parse_nested(tb, TCA_U32_MAX, opt, NULL) < 0)
-               return -EINVAL;
+       err = nla_parse_nested(tb, TCA_U32_MAX, opt, NULL);
+       if (err < 0)
+               return err;
 
        if ((n = (struct tc_u_knode*)*arg) != NULL) {
                if (TC_U32_KEY(n->handle) == 0)
index 92b6863e928d2261d7f418a94ec7b6aca718ab38..dd5723670d31e4f0ba4a8cacfdf9b38adf3d3b14 100644 (file)
@@ -749,14 +749,16 @@ static inline int meta_is_supported(struct meta_value *val)
 static int em_meta_change(struct tcf_proto *tp, void *data, int len,
                          struct tcf_ematch *m)
 {
-       int err = -EINVAL;
+       int err;
        struct nlattr *tb[TCA_EM_META_MAX + 1];
        struct tcf_meta_hdr *hdr;
        struct meta_match *meta = NULL;
 
-       if (nla_parse(tb, TCA_EM_META_MAX, data, len, NULL) < 0)
+       err = nla_parse(tb, TCA_EM_META_MAX, data, len, NULL);
+       if (err < 0)
                goto errout;
 
+       err = -EINVAL;
        if (tb[TCA_EM_META_HDR] == NULL ||
            nla_len(tb[TCA_EM_META_HDR]) < sizeof(*hdr))
                goto errout;
index 72d9b2735245d5bdb630c70cbe4dbb416aa6928d..d2b480f01a40608856b5f6168502ff36c7a75e31 100644 (file)
@@ -301,7 +301,7 @@ errout:
 int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla,
                         struct tcf_ematch_tree *tree)
 {
-       int idx, list_len, matches_len, err = -EINVAL;
+       int idx, list_len, matches_len, err;
        struct nlattr *tb[TCA_EMATCH_TREE_MAX + 1];
        struct nlattr *rt_match, *rt_hdr, *rt_list;
        struct tcf_ematch_tree_hdr *tree_hdr;
@@ -312,9 +312,11 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla,
                return 0;
        }
 
-       if (nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL) < 0)
+       err = nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL);
+       if (err < 0)
                goto errout;
 
+       err = -EINVAL;
        rt_hdr = tb[TCA_EMATCH_TREE_HDR];
        rt_list = tb[TCA_EMATCH_TREE_LIST];
 
index e587391537827dc7ee9d43f1743bcdc2daf16bee..aaa32a22726d1da6370f686db675ab9fdda06c40 100644 (file)
@@ -223,8 +223,12 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
         */
        if (flow)
                return -EBUSY;
-       if (opt == NULL || nla_parse_nested(tb, TCA_ATM_MAX, opt, NULL))
+       if (opt == NULL)
                return -EINVAL;
+       error = nla_parse_nested(tb, TCA_ATM_MAX, opt, NULL);
+       if (error < 0)
+               return error;
+
        if (!tb[TCA_ATM_FD] || nla_len(tb[TCA_ATM_FD]) < sizeof(fd))
                return -EINVAL;
        fd = *(int *)nla_data(tb[TCA_ATM_FD]);
index 5c8667ef4ba76b3f37feee31e2d0d64e008b5114..585f8a6ec7ec2315ea861f3c135a27585e9e8450 100644 (file)
@@ -1382,9 +1382,13 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
        struct cbq_sched_data *q = qdisc_priv(sch);
        struct nlattr *tb[TCA_CBQ_MAX + 1];
        struct tc_ratespec *r;
+       int err;
+
+       err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL);
+       if (err < 0)
+               return err;
 
-       if (nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL) < 0 ||
-           tb[TCA_CBQ_RTAB] == NULL || tb[TCA_CBQ_RATE] == NULL ||
+       if (tb[TCA_CBQ_RTAB] == NULL || tb[TCA_CBQ_RATE] == NULL ||
            nla_len(tb[TCA_CBQ_RATE]) < sizeof(struct tc_ratespec))
                return -EINVAL;
 
@@ -1764,9 +1768,13 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
        struct cbq_class *parent;
        struct qdisc_rate_table *rtab = NULL;
 
-       if (opt==NULL || nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL))
+       if (opt == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_CBQ_OVL_STRATEGY] &&
            nla_len(tb[TCA_CBQ_OVL_STRATEGY]) < sizeof(struct tc_cbq_ovl))
                return -EINVAL;
index f183ab7688738d23c3f019cf770a187f4826b09b..f1d0a08aca75fe53bad0ffa14cb5c2eb628fa252 100644 (file)
@@ -116,9 +116,14 @@ static int dsmark_change(struct Qdisc *sch, u32 classid, u32 parent,
                goto errout;
        }
 
-       if (!opt || nla_parse_nested(tb, TCA_DSMARK_MAX, opt, NULL))
+       if (!opt)
                goto errout;
 
+       err = nla_parse_nested(tb, TCA_DSMARK_MAX, opt, NULL);
+       if (err < 0)
+               return err;
+
+       err = -EINVAL;
        if (tb[TCA_DSMARK_MASK]) {
                if (nla_len(tb[TCA_DSMARK_MASK]) < sizeof(u8))
                        goto errout;
@@ -351,9 +356,14 @@ static int dsmark_init(struct Qdisc *sch, struct nlattr *opt)
 
        pr_debug("dsmark_init(sch %p,[qdisc %p],opt %p)\n", sch, p, opt);
 
-       if (!opt || nla_parse_nested(tb, TCA_DSMARK_MAX, opt, NULL) < 0)
+       if (!opt)
+               goto errout;
+
+       err = nla_parse_nested(tb, TCA_DSMARK_MAX, opt, NULL);
+       if (err < 0)
                goto errout;
 
+       err = -EINVAL;
        if (nla_len(tb[TCA_DSMARK_INDICES]) < sizeof(u16))
                goto errout;
        indices = nla_get_u16(tb[TCA_DSMARK_INDICES]);
index 6b784838a534df25c19015dcb19e48325a76bee2..365c7d8b17abd844298a881a4d723b8cab8fe969 100644 (file)
@@ -430,12 +430,16 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt)
        struct gred_sched *table = qdisc_priv(sch);
        struct tc_gred_qopt *ctl;
        struct nlattr *tb[TCA_GRED_MAX + 1];
-       int err = -EINVAL, prio = GRED_DEF_PRIO;
+       int err, prio = GRED_DEF_PRIO;
        u8 *stab;
 
-       if (opt == NULL || nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL))
+       if (opt == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_GRED_PARMS] == NULL && tb[TCA_GRED_STAB] == NULL)
                return gred_change_table_def(sch, opt);
 
@@ -445,6 +449,7 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt)
            nla_len(tb[TCA_GRED_STAB]) < 256)
                return -EINVAL;
 
+       err = -EINVAL;
        ctl = nla_data(tb[TCA_GRED_PARMS]);
        stab = nla_data(tb[TCA_GRED_STAB]);
 
@@ -489,10 +494,15 @@ errout:
 static int gred_init(struct Qdisc *sch, struct nlattr *opt)
 {
        struct nlattr *tb[TCA_GRED_MAX + 1];
+       int err;
 
-       if (opt == NULL || nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL))
+       if (opt == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_GRED_PARMS] || tb[TCA_GRED_STAB])
                return -EINVAL;
 
index 4e6a164d3058fa3e46ff7850671b4b5cb1109ad5..fcb4826158d65c561b66560961c4613910511096 100644 (file)
@@ -997,10 +997,15 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
        struct nlattr *tb[TCA_HFSC_MAX + 1];
        struct tc_service_curve *rsc = NULL, *fsc = NULL, *usc = NULL;
        u64 cur_time;
+       int err;
 
-       if (opt == NULL || nla_parse_nested(tb, TCA_HFSC_MAX, opt, NULL))
+       if (opt == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_HFSC_MAX, opt, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_HFSC_RSC]) {
                if (nla_len(tb[TCA_HFSC_RSC]) < sizeof(*rsc))
                        return -EINVAL;
index 3b3ff641b6d725e1823ff3e319c2d50d868f096d..512df9a0a2421b0fef79d21ac35236546a799a34 100644 (file)
@@ -997,9 +997,17 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)
        struct htb_sched *q = qdisc_priv(sch);
        struct nlattr *tb[TCA_HTB_INIT + 1];
        struct tc_htb_glob *gopt;
+       int err;
        int i;
-       if (!opt || nla_parse_nested(tb, TCA_HTB_INIT, opt, NULL) ||
-           tb[TCA_HTB_INIT] == NULL ||
+
+       if (!opt)
+               return -EINVAL;
+
+       err = nla_parse_nested(tb, TCA_HTB_INIT, opt, NULL);
+       if (err < 0)
+               return err;
+
+       if (tb[TCA_HTB_INIT] == NULL ||
            nla_len(tb[TCA_HTB_INIT]) < sizeof(*gopt)) {
                printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n");
                return -EINVAL;
@@ -1302,8 +1310,15 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
        struct tc_htb_opt *hopt;
 
        /* extract all subattrs from opt attr */
-       if (!opt || nla_parse_nested(tb, TCA_HTB_RTAB, opt, NULL) ||
-           tb[TCA_HTB_PARMS] == NULL ||
+       if (!opt)
+               goto failure;
+
+       err = nla_parse_nested(tb, TCA_HTB_RTAB, opt, NULL);
+       if (err < 0)
+               goto failure;
+
+       err = -EINVAL;
+       if (tb[TCA_HTB_PARMS] == NULL ||
            nla_len(tb[TCA_HTB_PARMS]) < sizeof(*hopt))
                goto failure;
 
index a4f932df86e93ffbc502d9983f1c7eeb8e938cdc..4aa2b45dad0a80232ed1d1d1c2fbabf33b19ec8f 100644 (file)
@@ -229,11 +229,14 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
        struct prio_sched_data *q = qdisc_priv(sch);
        struct tc_prio_qopt *qopt;
        struct nlattr *tb[TCA_PRIO_MAX + 1];
+       int err;
        int i;
 
-       if (nla_parse_nested_compat(tb, TCA_PRIO_MAX, opt, NULL, qopt,
-                                   sizeof(*qopt)))
-               return -EINVAL;
+       err = nla_parse_nested_compat(tb, TCA_PRIO_MAX, opt, NULL, qopt,
+                                     sizeof(*qopt));
+       if (err < 0)
+               return err;
+
        q->bands = qopt->bands;
        /* If we're multiqueue, make sure the number of incoming bands
         * matches the number of queues on the device we're associating with.
index 6ce8da5aca0ba64c902a989ef5725b96742093fd..dcf6afc196f88c4759afb2bd5a53b9e11b07089c 100644 (file)
@@ -207,10 +207,15 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
        struct nlattr *tb[TCA_RED_MAX + 1];
        struct tc_red_qopt *ctl;
        struct Qdisc *child = NULL;
+       int err;
 
-       if (opt == NULL || nla_parse_nested(tb, TCA_RED_MAX, opt, NULL))
+       if (opt == NULL)
                return -EINVAL;
 
+       err = nla_parse_nested(tb, TCA_RED_MAX, opt, NULL);
+       if (err < 0)
+               return err;
+
        if (tb[TCA_RED_PARMS] == NULL ||
            nla_len(tb[TCA_RED_PARMS]) < sizeof(*ctl) ||
            tb[TCA_RED_STAB] == NULL ||
index 6c4ad7e677b3486e43a65cc2a3424f7dbc15ec7f..f9b1543e3d7604abeb5c538e0840a053848953c5 100644 (file)
@@ -272,7 +272,7 @@ static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
 
 static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
 {
-       int err = -EINVAL;
+       int err;
        struct tbf_sched_data *q = qdisc_priv(sch);
        struct nlattr *tb[TCA_TBF_PTAB + 1];
        struct tc_tbf_qopt *qopt;
@@ -281,8 +281,12 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
        struct Qdisc *child = NULL;
        int max_size,n;
 
-       if (nla_parse_nested(tb, TCA_TBF_PTAB, opt, NULL) ||
-           tb[TCA_TBF_PARMS] == NULL ||
+       err = nla_parse_nested(tb, TCA_TBF_PTAB, opt, NULL);
+       if (err < 0)
+               return err;
+
+       err = -EINVAL;
+       if (tb[TCA_TBF_PARMS] == NULL ||
            nla_len(tb[TCA_TBF_PARMS]) < sizeof(*qopt))
                goto done;