netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Cong Wang <cwang@twopensource.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	netdev <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Wang Bo <wang.bo116@zte.com.cn>,
	John Fastabend <john.r.fastabend@intel.com>,
	Eric Dumazet <edumazet@google.com>, Terry Lam <vtlam@google.com>
Subject: Re: [Patch net 2/2] net_sched: always call ->destroy when ->init() fails
Date: Sat, 25 Oct 2014 01:44:04 +0100	[thread overview]
Message-ID: <20141025004403.GC11289@acer.localdomain> (raw)
In-Reply-To: <CAHA+R7M3y=Mj_L3yL0UM41mfGa+go+Kq4wYga7D6epY3uq_yWQ@mail.gmail.com>

On Fri, Oct 24, 2014 at 05:38:48PM -0700, Cong Wang wrote:
> On Fri, Oct 24, 2014 at 5:36 PM, Patrick McHardy <kaber@trash.net> wrote:
> >
> > Again, the correct fix is to make qdisc_create_dflt() not call
> > qdisc_destroy() but clean up the qdisc manually as done in
> > qdisc_create().
> 
> I kindly wish you a good luck with fixing all callers of qdisc_create_dflt().
> Go ahead. :)

Here you go:

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index fc04fe9..3a71e51 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -590,18 +590,21 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
 	struct Qdisc *sch;
 
 	if (!try_module_get(ops->owner))
-		goto errout;
+		goto err1;
 
 	sch = qdisc_alloc(dev_queue, ops);
 	if (IS_ERR(sch))
-		goto errout;
+		goto err2;
 	sch->parent = parentid;
 
 	if (!ops->init || ops->init(sch, NULL) == 0)
 		return sch;
 
-	qdisc_destroy(sch);
-errout:
+	dev_put(sch->dev_queue->dev);
+	kfree((char *)sch - sch->padded);
+err2:
+	module_put(ops->owner);
+err1:
 	return NULL;
 }
 EXPORT_SYMBOL(qdisc_create_dflt);

  reply	other threads:[~2014-10-25  0:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24 23:55 [Patch net 1/2] sch_pie: schedule the timer after all init succeed Cong Wang
2014-10-24 23:55 ` [Patch net 2/2] net_sched: always call ->destroy when ->init() fails Cong Wang
2014-10-25  0:14   ` Eric Dumazet
2014-10-25  0:36     ` Cong Wang
2014-10-25  0:40       ` Eric Dumazet
2014-10-25  0:42       ` Eric Dumazet
2014-10-25  0:36     ` Patrick McHardy
2014-10-25  0:38       ` Cong Wang
2014-10-25  0:44         ` Patrick McHardy [this message]
2014-10-25  0:53           ` Cong Wang
2014-10-25  1:04             ` Patrick McHardy
2014-10-28 19:58               ` David Miller
2014-10-29 18:29   ` David Miller
2014-10-30  3:09     ` John Fastabend
2014-10-25  0:17 ` [Patch net 1/2] sch_pie: schedule the timer after all init succeed Eric Dumazet
2014-10-25  0:28   ` Cong Wang
2014-10-25  0:39     ` Eric Dumazet
2014-10-25  0:42       ` Cong Wang
2014-10-29 18:28 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141025004403.GC11289@acer.localdomain \
    --to=kaber@trash.net \
    --cc=cwang@twopensource.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=john.r.fastabend@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=vtlam@google.com \
    --cc=wang.bo116@zte.com.cn \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).