]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
tc: propogate errors from tcf_hash_create
authorStephen Hemminger <shemminger@vyatta.com>
Wed, 26 Nov 2008 05:12:32 +0000 (21:12 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Nov 2008 05:13:25 +0000 (21:13 -0800)
Allow tcf_hash_create to return different errors on estimator failure.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
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_simple.c
net/sched/act_skbedit.c

index 8f457f1e0acf86b16911688b938b262f566669fb..9d03cc33b6ccbfab51e3fe65eadd10b3b84eb101 100644 (file)
@@ -214,12 +214,14 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind,
 }
 EXPORT_SYMBOL(tcf_hash_check);
 
-struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a, int size, int bind, u32 *idx_gen, struct tcf_hashinfo *hinfo)
+struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
+                                  struct tc_action *a, int size, int bind,
+                                  u32 *idx_gen, struct tcf_hashinfo *hinfo)
 {
        struct tcf_common *p = kzalloc(size, GFP_KERNEL);
 
        if (unlikely(!p))
-               return p;
+               return ERR_PTR(-ENOMEM);
        p->tcfc_refcnt = 1;
        if (bind)
                p->tcfc_bindcnt = 1;
@@ -228,9 +230,15 @@ struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, struct tc_acti
        p->tcfc_index = index ? index : tcf_hash_new_index(idx_gen, hinfo);
        p->tcfc_tm.install = jiffies;
        p->tcfc_tm.lastuse = jiffies;
-       if (est)
-               gen_new_estimator(&p->tcfc_bstats, &p->tcfc_rate_est,
-                                 &p->tcfc_lock, est);
+       if (est) {
+               int err = gen_new_estimator(&p->tcfc_bstats, &p->tcfc_rate_est,
+                                           &p->tcfc_lock, est);
+               if (err) {
+                       kfree(p);
+                       return ERR_PTR(err);
+               }
+       }
+
        a->priv = (void *) p;
        return p;
 }
index ac04289da5d74519234f0371072bd79064910375..e7f796aec657f90089a4872ab79c831b62bde467 100644 (file)
@@ -88,8 +88,8 @@ static int tcf_gact_init(struct nlattr *nla, struct nlattr *est,
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*gact),
                                     bind, &gact_idx_gen, &gact_hash_info);
-               if (unlikely(!pc))
-                       return -ENOMEM;
+               if (IS_ERR(pc))
+                   return PTR_ERR(pc);
                ret = ACT_P_CREATED;
        } else {
                if (!ovr) {
index 0453d79ebf570d985a702ca73194eda80dceae64..082c520b0def5d85f8ca8dc830d3ec20250cd758 100644 (file)
@@ -136,8 +136,8 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
        if (!pc) {
                pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind,
                                     &ipt_idx_gen, &ipt_hash_info);
-               if (unlikely(!pc))
-                       return -ENOMEM;
+               if (IS_ERR(pc))
+                   return PTR_ERR(pc);
                ret = ACT_P_CREATED;
        } else {
                if (!ovr) {
index 70341c020b6de33586e7fb02f41857c3770122cb..b9aaab4e03548a848c4f9bba9b527803fa602157 100644 (file)
@@ -105,8 +105,8 @@ static int tcf_mirred_init(struct nlattr *nla, struct nlattr *est,
                        return -EINVAL;
                pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind,
                                     &mirred_idx_gen, &mirred_hash_info);
-               if (unlikely(!pc))
-                       return -ENOMEM;
+               if (IS_ERR(pc))
+                   return PTR_ERR(pc);
                ret = ACT_P_CREATED;
        } else {
                if (!ovr) {
index 7b39ed485bca0beeb44da1572ff053ed61395d5f..d885ba311564d9a766fce6eac37edbaf0ed82b71 100644 (file)
@@ -68,8 +68,8 @@ static int tcf_nat_init(struct nlattr *nla, struct nlattr *est,
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
                                     &nat_idx_gen, &nat_hash_info);
-               if (unlikely(!pc))
-                       return -ENOMEM;
+               if (IS_ERR(pc))
+                   return PTR_ERR(pc);
                p = to_tcf_nat(pc);
                ret = ACT_P_CREATED;
        } else {
index d5f4e3404864eb7ffc70c3b7a79d425658e4ec53..96c0ed115e2a07d6b8ff7afe86632e03fb4174b9 100644 (file)
@@ -68,8 +68,8 @@ static int tcf_pedit_init(struct nlattr *nla, struct nlattr *est,
                        return -EINVAL;
                pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
                                     &pedit_idx_gen, &pedit_hash_info);
-               if (unlikely(!pc))
-                       return -ENOMEM;
+               if (IS_ERR(pc))
+                   return PTR_ERR(pc);
                p = to_pedit(pc);
                keys = kmalloc(ksize, GFP_KERNEL);
                if (keys == NULL) {
index e7851ce92cfea56cef8ba52943cbbba5a1942b68..8daa1ebc7413b971dafde75606af039d52a7e83e 100644 (file)
@@ -124,8 +124,8 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
                                     &simp_idx_gen, &simp_hash_info);
-               if (unlikely(!pc))
-                       return -ENOMEM;
+               if (IS_ERR(pc))
+                   return PTR_ERR(pc);
 
                d = to_defact(pc);
                ret = alloc_defdata(d, defdata);
index fe9777e77f3582a3d50bcba78caac038d00f94f6..4ab916b8074be28daea9fe9f329b4b3b460132c7 100644 (file)
@@ -104,8 +104,8 @@ static int tcf_skbedit_init(struct nlattr *nla, struct nlattr *est,
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
                                     &skbedit_idx_gen, &skbedit_hash_info);
-               if (unlikely(!pc))
-                       return -ENOMEM;
+               if (IS_ERR(pc))
+                   return PTR_ERR(pc);
 
                d = to_skbedit(pc);
                ret = ACT_P_CREATED;