From: Jarek Poplawski Date: Wed, 16 Sep 2009 06:42:05 +0000 (-0700) Subject: pkt_sched: Fix qdisc_create on stab error handling X-Git-Tag: v2.6.32-rc1~21^2~66 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=7c64b9f3f584008000cf3b960f25cd6a68fce191;p=linux-2.6-block.git pkt_sched: Fix qdisc_create on stab error handling 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 Signed-off-by: David S. Miller --- diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 1367aa21fad5..903e4188b6ca 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -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; } @@ -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: @@ -852,6 +851,7 @@ err_out4: * 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;