Skip to content

Commit 32039ea

Browse files
w1ldptrdavem330
authored andcommitted
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: 4e8ddd7 ("net: sched: don't release reference on action overwrite") Reported-by: Cong Wang <[email protected]> Signed-off-by: Vlad Buslov <[email protected]> Acked-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5f34f69 commit 32039ea

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

net/sched/act_ife.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,6 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
551551
NULL, NULL);
552552
if (err) {
553553
metadata_parse_err:
554-
if (ret == ACT_P_CREATED)
555-
tcf_idr_release(*a, bind);
556-
557554
if (exists)
558555
spin_unlock_bh(&ife->tcf_lock);
559556
tcf_idr_release(*a, bind);
@@ -574,11 +571,10 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
574571
*/
575572
err = use_all_metadata(ife);
576573
if (err) {
577-
if (ret == ACT_P_CREATED)
578-
tcf_idr_release(*a, bind);
579-
580574
if (exists)
581575
spin_unlock_bh(&ife->tcf_lock);
576+
tcf_idr_release(*a, bind);
577+
582578
kfree(p);
583579
return err;
584580
}

0 commit comments

Comments
 (0)