Skip to content

Commit

Permalink
pkt_sched: Fix qdisc_create on stab error handling
Browse files Browse the repository at this point in the history
If qdisc_get_stab returns error in qdisc_create there is skipped qdisc
ops->destroy, which is necessary because it's after ops->init at the
moment, so memory leaks are quite probable.

Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jarek Poplawski authored and David S. Miller committed Sep 16, 2009
1 parent 926e61b commit 7c64b9f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
stab = qdisc_get_stab(tca[TCA_STAB]);
if (IS_ERR(stab)) {
err = PTR_ERR(stab);
goto err_out3;
goto err_out4;
}
sch->stab = stab;
}
Expand Down Expand Up @@ -838,7 +838,6 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
return sch;
}
err_out3:
qdisc_put_stab(sch->stab);
dev_put(dev);
kfree((char *) sch - sch->padded);
err_out2:
Expand All @@ -852,6 +851,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
* Any broken qdiscs that would require a ops->reset() here?
* The qdisc was never in action so it shouldn't be necessary.
*/
qdisc_put_stab(sch->stab);
if (ops->destroy)
ops->destroy(sch);
goto err_out3;
Expand Down

0 comments on commit 7c64b9f

Please sign in to comment.