sch_tbf: Fix potential memory leak in tbf_change().
Subsystems (3)
PATCH 1/1 sch_tbf: Fix potential memory leak in tbf_change().
The allocated child qdisc is not freed in error conditions. Defer the allocation after user configuration turns out to be valid and acceptable.
--- net/sched/sch_tbf.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
net/sched/sch_tbf.c +12 -12
@@ -334,18 +334,6 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)qdisc_put_rtab (qdisc_get_rtab (&qopt->peakrate, tb[TCA_TBF_PTAB ])); -if (q->qdisc != &noop_qdisc) { - err =fifo_set_limit (q->qdisc, qopt->limit); -if (err) - goto done; - }else if (qopt->limit >0 ) { - child =fifo_create_dflt (sch, &bfifo_qdisc_ops, qopt->limit); -if (IS_ERR (child)) { - err =PTR_ERR (child); - goto done; - } - } - buffer =min_t (u64,PSCHED_TICKS2NS (qopt->buffer), ~0U ); mtu =min_t (u64,PSCHED_TICKS2NS (qopt->mtu), ~0U );
@@ -390,6 +378,18 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt) goto done; } +if (q->qdisc != &noop_qdisc) { + err =fifo_set_limit (q->qdisc, qopt->limit); +if (err) + goto done; + }else if (qopt->limit >0 ) { + child =fifo_create_dflt (sch, &bfifo_qdisc_ops, qopt->limit); +if (IS_ERR (child)) { + err =PTR_ERR (child); + goto done; + } + } +sch_tree_lock (sch);if (child) {qdisc_tree_decrease_qlen (q->qdisc, q->qdisc->q.qlen);
Signature · 1 line
1.8.3.2
Quoted 5 lines · Hiroaki SHIMODA
The allocated child qdisc is not freed in error conditions. Defer the allocation after user configuration turns out to be valid and acceptable.
Fixes cc106e4 ("net: sched: tbf: fix the calculation of max_size")
Please prefer/use 12 digits : cc106e441a63b
You can put in your .git/config file :
[core]
... abbrev = 12 ...
Quoted 3 lines
Signed-off-by Hiroaki SHIMODA <[email protected]>Cc Yang Yingliang <[email protected]>---
Thanks
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Wed, 26 Feb 2014 07:29:44 -0800
Quoted 8 lines · Hiroaki SHIMODA
Quoted 5 lines
The allocated child qdisc is not freed in error conditions. Defer the allocation after user configuration turns out to be valid and acceptable.
Fixes cc106e4 ("net: sched: tbf: fix the calculation of max_size")Please prefer/use 12 digits :
cc106e441a63b
Applied with SHA1 adjustment, thanks.
Quoted 7 lines · On Wed, 26 Feb 2014 07:29:44 -0800 Eric Dumazet <[email protected]> wrote:
Quoted 5 lines · Hiroaki SHIMODA
The allocated child qdisc is not freed in error conditions. Defer the allocation after user configuration turns out to be valid and acceptable.
Fixes cc106e4 ("net: sched: tbf: fix the calculation of max_size")
Quoted 8 lines
Please prefer/use 12 digits :
cc106e441a63bYou can put in your .git/config file :
[core]
... abbrev = 12 ...
Thank you for your kind suggestion.
I will use 12 digits next time.
Quoted 9 lines
Quoted 3 lines
Signed-off-by Hiroaki SHIMODA <[email protected]>Cc Yang Yingliang <[email protected]>---
Acked-by Eric Dumazet <[email protected]>Thanks