netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] sch_tbf: Fix potential memory leak in tbf_change().
@ 2014-02-26 12:43 Hiroaki SHIMODA
  2014-02-26 15:29 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Hiroaki SHIMODA @ 2014-02-26 12:43 UTC (permalink / raw)
  To: davem; +Cc: netdev, yangyingliang

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")
Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Cc: Yang Yingliang <yangyingliang@huawei.com>
---
 net/sched/sch_tbf.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 1cb413f..4f505a0 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -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);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] sch_tbf: Fix potential memory leak in tbf_change().
  2014-02-26 12:43 [PATCH net] sch_tbf: Fix potential memory leak in tbf_change() Hiroaki SHIMODA
@ 2014-02-26 15:29 ` Eric Dumazet
  2014-02-26 22:32   ` David Miller
  2014-02-26 22:43   ` Hiroaki SHIMODA
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2014-02-26 15:29 UTC (permalink / raw)
  To: Hiroaki SHIMODA; +Cc: davem, netdev, yangyingliang

On Wed, 2014-02-26 at 21:43 +0900, Hiroaki SHIMODA wrote:
> 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
	...

> Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
> Cc: Yang Yingliang <yangyingliang@huawei.com>
> ---

Acked-by: Eric Dumazet <edumazet@google.com>

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] sch_tbf: Fix potential memory leak in tbf_change().
  2014-02-26 15:29 ` Eric Dumazet
@ 2014-02-26 22:32   ` David Miller
  2014-02-26 22:43   ` Hiroaki SHIMODA
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-02-26 22:32 UTC (permalink / raw)
  To: eric.dumazet; +Cc: shimoda.hiroaki, netdev, yangyingliang

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 26 Feb 2014 07:29:44 -0800

> On Wed, 2014-02-26 at 21:43 +0900, Hiroaki SHIMODA wrote:
>> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] sch_tbf: Fix potential memory leak in tbf_change().
  2014-02-26 15:29 ` Eric Dumazet
  2014-02-26 22:32   ` David Miller
@ 2014-02-26 22:43   ` Hiroaki SHIMODA
  1 sibling, 0 replies; 4+ messages in thread
From: Hiroaki SHIMODA @ 2014-02-26 22:43 UTC (permalink / raw)
  To: eric.dumazet; +Cc: davem, netdev, yangyingliang

On Wed, 26 Feb 2014 07:29:44 -0800
Eric Dumazet <eric.dumazet@gmail.com> wrote:

> On Wed, 2014-02-26 at 21:43 +0900, Hiroaki SHIMODA wrote:
> > 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
> 	...

Thank you for your kind suggestion.
I will use 12 digits next time.

> > Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
> > Cc: Yang Yingliang <yangyingliang@huawei.com>
> > ---
> 
> Acked-by: Eric Dumazet <edumazet@google.com>
> 
> Thanks
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-26 22:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-26 12:43 [PATCH net] sch_tbf: Fix potential memory leak in tbf_change() Hiroaki SHIMODA
2014-02-26 15:29 ` Eric Dumazet
2014-02-26 22:32   ` David Miller
2014-02-26 22:43   ` Hiroaki SHIMODA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).