Skip to content

Commit

Permalink
qdisc: fix a module refcount leak in qdisc_create_dflt()
Browse files Browse the repository at this point in the history
Should qdisc_alloc() fail, we must release the module refcount
we got right before.

Fixes: 6da7c8f ("qdisc: allow setting default queuing discipline")
Signed-off-by: Eric Dumazet <[email protected]>
Acked-by: John Fastabend <[email protected]>
Acked-by: John Fastabend <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Aug 25, 2016
1 parent a5de125 commit 166ee5b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions net/sched/sch_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 166ee5b

Please sign in to comment.