]> git.hungrycats.org Git - linux/commitdiff
[PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
authorPatrick McHardy <kaber@trash.net>
Wed, 24 Dec 2003 11:17:22 +0000 (03:17 -0800)
committerDavid S. Miller <davem@nuts.ninka.net>
Wed, 24 Dec 2003 11:17:22 +0000 (03:17 -0800)
Create common routine, tcf_destroy(), that does all the work properly
in one centralized place.

include/net/pkt_cls.h
net/sched/cls_api.c
net/sched/sch_atm.c
net/sched/sch_cbq.c
net/sched/sch_csz.c
net/sched/sch_dsmark.c
net/sched/sch_htb.c
net/sched/sch_ingress.c
net/sched/sch_prio.c

index 887987f4ba91d1341682808e3270df92b51c3ba2..ca07367721df60edeee4e00ef82b6317ad5d8372 100644 (file)
@@ -81,7 +81,12 @@ static inline int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, struct
        return -1;
 }
 
-
+static inline void tcf_destroy(struct tcf_proto *tp)
+{
+       tp->ops->destroy(tp);
+       module_put(tp->ops->owner);
+       kfree(tp);
+}
 
 extern int register_tcf_proto_ops(struct tcf_proto_ops *ops);
 extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
index 78fa65d6f487c4f308e566c2247c419c0ced7cf6..f50691da2348eb9dd4305973626fe4dad37b24a2 100644 (file)
@@ -247,10 +247,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
                        *back = tp->next;
                        spin_unlock_bh(&dev->queue_lock);
                        write_unlock(&qdisc_tree_lock);
-
-                       tp->ops->destroy(tp);
-                       module_put(tp->ops->owner);
-                       kfree(tp);
+                       tcf_destroy(tp);
                        err = 0;
                        goto errout;
                }
index a6d9728d3aa1506e63aa0e457d9c86ce6017a252..8dfaf3f38b5295ca442a348dabfade11c75d28c7 100644 (file)
@@ -162,7 +162,7 @@ static void destroy_filters(struct atm_flow_data *flow)
        while ((filter = flow->filter_list)) {
                DPRINTK("destroy_filters: destroying filter %p\n",filter);
                flow->filter_list = filter->next;
-               filter->ops->destroy(filter);
+               tcf_destroy(filter);
        }
 }
 
index d30c5f38ba97fa7a5c8e071022767de4c8b8863b..fad828b45c9d3bd3e09b019ee0a2238b3f383248 100644 (file)
@@ -1705,7 +1705,7 @@ static void cbq_destroy_filters(struct cbq_class *cl)
 
        while ((tp = cl->filter_list) != NULL) {
                cl->filter_list = tp->next;
-               tp->ops->destroy(tp);
+               tcf_destroy(tp);
        }
 }
 
index 2f4ed4c3cb8d235f795133947a86ca0ccce59393..4bbb60b13c9d4ed4aca6df83887693f4b5bd9471 100644 (file)
@@ -752,7 +752,7 @@ csz_destroy(struct Qdisc* sch)
 
        while ((tp = q->filter_list) != NULL) {
                q->filter_list = tp->next;
-               tp->ops->destroy(tp);
+               tcf_destroy(tp);
        }
 }
 
index 8db00228c0a42dbda910574148e59c2bd55ae216..3470a40c382055d828d4f2306b60e5615ba05f88 100644 (file)
@@ -378,7 +378,7 @@ static void dsmark_destroy(struct Qdisc *sch)
        while (p->filter_list) {
                tp = p->filter_list;
                p->filter_list = tp->next;
-               tp->ops->destroy(tp);
+               tcf_destroy(tp);
        }
        qdisc_destroy(p->q);
        p->q = &noop_qdisc;
index 4cc5d5f8366b635efdbd7eb197bd2e7ff8a603cd..a3216cc06c55c1fa29412afb427eac5cda08a4d5 100644 (file)
@@ -1338,7 +1338,7 @@ static void htb_destroy_filters(struct tcf_proto **fl)
 
        while ((tp = *fl) != NULL) {
                *fl = tp->next;
-               tp->ops->destroy(tp);
+               tcf_destroy(tp);
        }
 }
 
index 5a63a85d84b22c403ec806ebe47bc0bba78af435..71ecbcbc83ca77e935b3421fdd225baf51095e1f 100644 (file)
@@ -292,7 +292,7 @@ static void ingress_destroy(struct Qdisc *sch)
        while (p->filter_list) {
                tp = p->filter_list;
                p->filter_list = tp->next;
-               tp->ops->destroy(tp);
+               tcf_destroy(tp);
        }
        memset(p, 0, sizeof(*p));
        p->filter_list = NULL;
index 7691f8ab78f2b62cb09cb02af82ea59fabcab09a..6c76742a3a03cc3824ffcc57d0529c3c41b36970 100644 (file)
@@ -162,7 +162,7 @@ prio_destroy(struct Qdisc* sch)
 
        while ((tp = q->filter_list) != NULL) {
                q->filter_list = tp->next;
-               tp->ops->destroy(tp);
+               tcf_destroy(tp);
        }
 
        for (prio=0; prio<q->bands; prio++) {