提交 32039eac 编写于 作者: V Vlad Buslov 提交者: David S. Miller

net: sched: act_ife: always release ife action on init error

Action init API was changed to always take reference to action, even when
overwriting existing action. Substitute conditional action release, which
was executed only if action is newly created, with unconditional release in
tcf_ife_init() error handling code to prevent double free or memory leak in
case of overwrite.

Fixes: 4e8ddd7f ("net: sched: don't release reference on action overwrite")
Reported-by: NCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: NVlad Buslov <vladbu@mellanox.com>
Acked-by: NCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5f34f69e
...@@ -551,9 +551,6 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, ...@@ -551,9 +551,6 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
NULL, NULL); NULL, NULL);
if (err) { if (err) {
metadata_parse_err: metadata_parse_err:
if (ret == ACT_P_CREATED)
tcf_idr_release(*a, bind);
if (exists) if (exists)
spin_unlock_bh(&ife->tcf_lock); spin_unlock_bh(&ife->tcf_lock);
tcf_idr_release(*a, bind); tcf_idr_release(*a, bind);
...@@ -574,11 +571,10 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, ...@@ -574,11 +571,10 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
*/ */
err = use_all_metadata(ife); err = use_all_metadata(ife);
if (err) { if (err) {
if (ret == ACT_P_CREATED)
tcf_idr_release(*a, bind);
if (exists) if (exists)
spin_unlock_bh(&ife->tcf_lock); spin_unlock_bh(&ife->tcf_lock);
tcf_idr_release(*a, bind);
kfree(p); kfree(p);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册