Skip to content

Commit 306381a

Browse files
congwangdavem330
authored andcommitted
net_sched: fix a memory leak in atm_tc_init()
When tcf_block_get() fails inside atm_tc_init(), atm_tc_put() is called to release the qdisc p->link.q. But the flow->ref prevents it to do so, as the flow->ref is still zero. Fix this by moving the p->link.ref initialization before tcf_block_get(). Fixes: 6529eab ("net: sched: introduce tcf block infractructure") Reported-and-tested-by: [email protected] Cc: Jamal Hadi Salim <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 13cf8aa commit 306381a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/sched/sch_atm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,16 +553,16 @@ static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt,
553553
if (!p->link.q)
554554
p->link.q = &noop_qdisc;
555555
pr_debug("atm_tc_init: link (%p) qdisc %p\n", &p->link, p->link.q);
556+
p->link.vcc = NULL;
557+
p->link.sock = NULL;
558+
p->link.common.classid = sch->handle;
559+
p->link.ref = 1;
556560

557561
err = tcf_block_get(&p->link.block, &p->link.filter_list, sch,
558562
extack);
559563
if (err)
560564
return err;
561565

562-
p->link.vcc = NULL;
563-
p->link.sock = NULL;
564-
p->link.common.classid = sch->handle;
565-
p->link.ref = 1;
566566
tasklet_init(&p->task, sch_atm_dequeue, (unsigned long)sch);
567567
return 0;
568568
}

0 commit comments

Comments
 (0)