All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] qdisc: fix a module refcount leak in qdisc_create_dflt()
@ 2016-08-24 16:39 Eric Dumazet
  2016-08-24 17:13 ` John Fastabend
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Eric Dumazet @ 2016-08-24 16:39 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, John Fastabend, stephen hemminger, Jamal Hadi Salim

From: Eric Dumazet <edumazet@google.com>

Should qdisc_alloc() fail, we must release the module refcount
we got right before.

Fixes: 6da7c8fcbcbd ("qdisc: allow setting default queuing discipline")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/sched/sch_generic.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index e95b67cd5718..657c13362b19 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -643,18 +643,19 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
 	struct Qdisc *sch;
 
 	if (!try_module_get(ops->owner))
-		goto errout;
+		return NULL;
 
 	sch = qdisc_alloc(dev_queue, ops);
-	if (IS_ERR(sch))
-		goto errout;
+	if (IS_ERR(sch)) {
+		module_put(ops->owner);
+		return NULL;
+	}
 	sch->parent = parentid;
 
 	if (!ops->init || ops->init(sch, NULL) == 0)
 		return sch;
 
 	qdisc_destroy(sch);
-errout:
 	return NULL;
 }
 EXPORT_SYMBOL(qdisc_create_dflt);

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

end of thread, other threads:[~2016-08-25 23:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24 16:39 [PATCH net] qdisc: fix a module refcount leak in qdisc_create_dflt() Eric Dumazet
2016-08-24 17:13 ` John Fastabend
2016-08-24 17:14 ` John Fastabend
2016-08-25 13:26 ` Wei Yongjun
2016-08-25 14:46   ` Eric Dumazet
2016-08-25 23:44 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.