Skip to content

Commit

Permalink
sch_fq_codel: avoid double free on init failure
Browse files Browse the repository at this point in the history
It is very unlikely to happen but the backlogs memory allocation
could fail and will free q->flows, but then ->destroy() will free
q->flows too. For correctness remove the first free and let ->destroy
clean up.

Fixes: 87b60cf ("net_sched: fix error recovery at qdisc creation")
Signed-off-by: Nikolay Aleksandrov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Nikolay Aleksandrov authored and davem330 committed Aug 30, 2017
1 parent 3501d05 commit 30c31d7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/sched/sch_fq_codel.c
Original file line number Diff line number Diff line change
@@ -491,10 +491,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)
if (!q->flows)
return -ENOMEM;
q->backlogs = kvzalloc(q->flows_cnt * sizeof(u32), GFP_KERNEL);
if (!q->backlogs) {
kvfree(q->flows);
if (!q->backlogs)
return -ENOMEM;
}
for (i = 0; i < q->flows_cnt; i++) {
struct fq_codel_flow *flow = q->flows + i;

0 comments on commit 30c31d7

Please sign in to comment.