Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / net / sched / act_pedit.c
index d5eff6a..3ad7185 100644 (file)
@@ -43,7 +43,7 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
        int err = -EINVAL;
        int rem;
 
-       if (!nla || !n)
+       if (!nla)
                return NULL;
 
        keys_ex = kcalloc(n, sizeof(*k), GFP_KERNEL);
@@ -171,6 +171,10 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
        }
 
        parm = nla_data(pattr);
+       if (!parm->nkeys) {
+               NL_SET_ERR_MSG_MOD(extack, "Pedit requires keys to be passed");
+               return -EINVAL;
+       }
        ksize = parm->nkeys * sizeof(struct tc_pedit_key);
        if (nla_len(pattr) < sizeof(*parm) + ksize) {
                NL_SET_ERR_MSG_ATTR(extack, pattr, "Length of TCA_PEDIT_PARMS or TCA_PEDIT_PARMS_EX pedit attribute is invalid");
@@ -184,12 +188,6 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
        index = parm->index;
        err = tcf_idr_check_alloc(tn, &index, a, bind);
        if (!err) {
-               if (!parm->nkeys) {
-                       tcf_idr_cleanup(tn, index);
-                       NL_SET_ERR_MSG_MOD(extack, "Pedit requires keys to be passed");
-                       ret = -EINVAL;
-                       goto out_free;
-               }
                ret = tcf_idr_create(tn, index, est, a,
                                     &act_pedit_ops, bind, false, 0);
                if (ret) {