summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlad Buslov <vladbu@mellanox.com>2018-08-14 13:29:56 -0400
committerDavid S. Miller <davem@davemloft.net>2018-08-16 15:12:12 -0400
commit32039eac4c48f70dfaad36a84f30356ededc7ea8 (patch)
treee032ecc8fe44d5c4534999e5bdd97e1cced66080
parent5f34f69ede27dea1f167a0a6d8996f0194b27ba8 (diff)
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: 4e8ddd7f1758 ("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>
-rw-r--r--net/sched/act_ife.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index fdb928ca81bb..d1081bdf1bdb 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -551,9 +551,6 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
551 NULL, NULL); 551 NULL, NULL);
552 if (err) { 552 if (err) {
553metadata_parse_err: 553metadata_parse_err:
554 if (ret == ACT_P_CREATED)
555 tcf_idr_release(*a, bind);
556
557 if (exists) 554 if (exists)
558 spin_unlock_bh(&ife->tcf_lock); 555 spin_unlock_bh(&ife->tcf_lock);
559 tcf_idr_release(*a, bind); 556 tcf_idr_release(*a, bind);
@@ -574,11 +571,10 @@ metadata_parse_err:
574 */ 571 */
575 err = use_all_metadata(ife); 572 err = use_all_metadata(ife);
576 if (err) { 573 if (err) {
577 if (ret == ACT_P_CREATED)
578 tcf_idr_release(*a, bind);
579
580 if (exists) 574 if (exists)
581 spin_unlock_bh(&ife->tcf_lock); 575 spin_unlock_bh(&ife->tcf_lock);
576 tcf_idr_release(*a, bind);
577
582 kfree(p); 578 kfree(p);
583 return err; 579 return err;
584 } 580 }