On Tue, Apr 18, 2017 at 7:21 PM, Jamal Hadi Salim <j...@mojatatu.com> wrote:
> Indeed. Allocate the cookie before init? That way, we fail early
> and dont need to worry about restoring anything.

No, a->act_cookie needs an action pointer first. ;)

> In the case of a replace, do you really want to call tcf_hash_release?
>

Good point. Probably no, we already call it inside ->init().

Something like this...

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 82b1d48d91cc..29ffc348fe2f 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -609,14 +609,12 @@ struct tc_action *tcf_action_init_1(struct net
*net, struct nlattr *nla,

                if (cklen > TC_COOKIE_MAX_SIZE) {
                        err = -EINVAL;
-                       tcf_hash_release(a, bind);
-                       goto err_mod;
+                       goto err_release;
                }

                if (nla_memdup_cookie(a, tb) < 0) {
                        err = -ENOMEM;
-                       tcf_hash_release(a, bind);
-                       goto err_mod;
+                       goto err_release;
                }
        }

@@ -629,6 +627,9 @@ struct tc_action *tcf_action_init_1(struct net
*net, struct nlattr *nla,

        return a;

+err_release:
+       if (err == ACT_P_CREATED)
+               tcf_hash_release(a, bind);
 err_mod:
        module_put(a_o->owner);
 err_out:

Reply via email to