Skip to content

Commit

Permalink
net: sched: act_ife: always release ife action on init error
Browse files Browse the repository at this point in the history
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: 4e8ddd7 ("net: sched: don't release reference on action overwrite")
Reported-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Buslov authored and David S. Miller committed Aug 16, 2018
1 parent 5f34f69 commit 32039ea
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions net/sched/act_ife.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,6 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
NULL, NULL);
if (err) {
metadata_parse_err:
if (ret == ACT_P_CREATED)
tcf_idr_release(*a, bind);

if (exists)
spin_unlock_bh(&ife->tcf_lock);
tcf_idr_release(*a, bind);
Expand All @@ -574,11 +571,10 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
*/
err = use_all_metadata(ife);
if (err) {
if (ret == ACT_P_CREATED)
tcf_idr_release(*a, bind);

if (exists)
spin_unlock_bh(&ife->tcf_lock);
tcf_idr_release(*a, bind);

kfree(p);
return err;
}
Expand Down

0 comments on commit 32039ea

Please sign in to comment.