summaryrefslogtreecommitdiffstats
path: root/net/sched/act_ife.c
diff options
context:
space:
mode:
authorVlad Buslov <vladbu@mellanox.com>2018-07-05 17:24:30 +0300
committerDavid S. Miller <davem@davemloft.net>2018-07-08 12:42:29 +0900
commit4e8ddd7f1758ca4ddd0c1f7cf3e66fce736241d2 (patch)
tree645aad92e91829027f16cb33553063ac88cf6442 /net/sched/act_ife.c
parent16af6067392c40e454e49eec834843ab03643d96 (diff)
downloadlinux-stable-4e8ddd7f1758ca4ddd0c1f7cf3e66fce736241d2.tar.gz
linux-stable-4e8ddd7f1758ca4ddd0c1f7cf3e66fce736241d2.tar.bz2
linux-stable-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_ife.c')
-rw-r--r--net/sched/act_ife.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 89a761395c94..acea3feae762 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -498,12 +498,10 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
return ret;
}
ret = ACT_P_CREATED;
- } else {
+ } else if (!ovr) {
tcf_idr_release(*a, bind);
- if (!ovr) {
- kfree(p);
- return -EEXIST;
- }
+ kfree(p);
+ return -EEXIST;
}
ife = to_ife(*a);
@@ -548,6 +546,8 @@ metadata_parse_err:
if (exists)
spin_unlock_bh(&ife->tcf_lock);
+ tcf_idr_release(*a, bind);
+
kfree(p);
return err;
}