summaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>2017-08-30 12:49:02 +0300
committerBen Hutchings <ben@decadent.org.uk>2017-11-11 13:33:35 +0000
commit191fd165da1de27a2a61267f18eb65419ea938d5 (patch)
treee3734b8a0cdf130e1129335add4d06f63dd8ae17 /net/sched
parentaddb3a32b0ed9de074b9c84b094b060141fcfa94 (diff)
downloadlinux-stable-191fd165da1de27a2a61267f18eb65419ea938d5.tar.gz
linux-stable-191fd165da1de27a2a61267f18eb65419ea938d5.tar.bz2
linux-stable-191fd165da1de27a2a61267f18eb65419ea938d5.zip
sch_fq_codel: avoid double free on init failure
commit 30c31d746d0eb458ae327f522bc8e4c44cbea0f0 upstream. 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: 87b60cfacf9f ("net_sched: fix error recovery at qdisc creation") Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> [bwh: Backported to 3.16: fq_codel used different alloc/free functions] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/sch_fq_codel.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
index 633be4b72e20..3de2fd89e7fe 100644
--- a/net/sched/sch_fq_codel.c
+++ b/net/sched/sch_fq_codel.c
@@ -411,10 +411,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)
if (!q->flows)
return -ENOMEM;
q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32));
- if (!q->backlogs) {
- fq_codel_free(q->flows);
+ if (!q->backlogs)
return -ENOMEM;
- }
for (i = 0; i < q->flows_cnt; i++) {
struct fq_codel_flow *flow = q->flows + i;