diff options
author | Vlad Buslov <vladbu@mellanox.com> | 2018-07-05 16:24:30 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-08 05:42:29 +0200 |
commit | 4e8ddd7f1758ca4ddd0c1f7cf3e66fce736241d2 (patch) | |
tree | 645aad92e91829027f16cb33553063ac88cf6442 /net/sched/act_police.c | |
parent | net: sched: implement reference counted action release (diff) | |
download | linux-4e8ddd7f1758ca4ddd0c1f7cf3e66fce736241d2.tar.xz linux-4e8ddd7f1758ca4ddd0c1f7cf3e66fce736241d2.zip |
net: sched: don't release reference on action overwrite
Return from action init function with reference to action taken,
even when overwriting existing action.
Action init API initializes its fourth argument (pointer to pointer to tc
action) to either existing action with same index or newly created action.
In case of existing index(and bind argument is zero), init function returns
without incrementing action reference counter. Caller of action init then
proceeds working with action, without actually holding reference to it.
This means that action could be deleted concurrently.
Change action init behavior to always take reference to action before
returning successfully, in order to protect from concurrent deletion.
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_police.c')
-rw-r--r-- | net/sched/act_police.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/net/sched/act_police.c b/net/sched/act_police.c index c955fb0d4f3f..99335cca739e 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -111,10 +111,9 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla, if (ret) return ret; ret = ACT_P_CREATED; - } else { + } else if (!ovr) { tcf_idr_release(*a, bind); - if (!ovr) - return -EEXIST; + return -EEXIST; } police = to_police(*a); @@ -195,8 +194,7 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla, failure: qdisc_put_rtab(P_tab); qdisc_put_rtab(R_tab); - if (ret == ACT_P_CREATED) - tcf_idr_release(*a, bind); + tcf_idr_release(*a, bind); return err; } |