# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2003/12/24 19:17:22-08:00 kaber@trash.net 
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# net/sched/sch_prio.c
#   2003/12/24 19:17:10-08:00 kaber@trash.net +1 -1
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# net/sched/sch_ingress.c
#   2003/12/24 19:17:10-08:00 kaber@trash.net +1 -1
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# net/sched/sch_htb.c
#   2003/12/24 19:17:10-08:00 kaber@trash.net +1 -1
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# net/sched/sch_dsmark.c
#   2003/12/24 19:17:10-08:00 kaber@trash.net +1 -1
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# net/sched/sch_csz.c
#   2003/12/24 19:17:10-08:00 kaber@trash.net +1 -1
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# net/sched/sch_cbq.c
#   2003/12/24 19:17:10-08:00 kaber@trash.net +1 -1
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# net/sched/sch_atm.c
#   2003/12/24 19:17:10-08:00 kaber@trash.net +1 -1
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# net/sched/cls_api.c
#   2003/12/24 19:17:10-08:00 kaber@trash.net +1 -4
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
# include/net/pkt_cls.h
#   2003/12/24 19:17:10-08:00 kaber@trash.net +6 -1
#   [PKT_SCHED]: Fix module refcount and mem leaks in classful qdiscs.
#   
#   Create common routine, tcf_destroy(), that does all the work properly
#   in one centralized place.
# 
diff -Nru a/include/net/pkt_cls.h b/include/net/pkt_cls.h
--- a/include/net/pkt_cls.h	Tue Jan  6 06:37:39 2004
+++ b/include/net/pkt_cls.h	Tue Jan  6 06:37:39 2004
@@ -81,7 +81,12 @@
 	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);
diff -Nru a/net/sched/cls_api.c b/net/sched/cls_api.c
--- a/net/sched/cls_api.c	Tue Jan  6 06:37:39 2004
+++ b/net/sched/cls_api.c	Tue Jan  6 06:37:39 2004
@@ -247,10 +247,7 @@
 			*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;
 		}
diff -Nru a/net/sched/sch_atm.c b/net/sched/sch_atm.c
--- a/net/sched/sch_atm.c	Tue Jan  6 06:37:39 2004
+++ b/net/sched/sch_atm.c	Tue Jan  6 06:37:39 2004
@@ -162,7 +162,7 @@
 	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);
 	}
 }
 
diff -Nru a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
--- a/net/sched/sch_cbq.c	Tue Jan  6 06:37:39 2004
+++ b/net/sched/sch_cbq.c	Tue Jan  6 06:37:39 2004
@@ -1705,7 +1705,7 @@
 
 	while ((tp = cl->filter_list) != NULL) {
 		cl->filter_list = tp->next;
-		tp->ops->destroy(tp);
+		tcf_destroy(tp);
 	}
 }
 
diff -Nru a/net/sched/sch_csz.c b/net/sched/sch_csz.c
--- a/net/sched/sch_csz.c	Tue Jan  6 06:37:39 2004
+++ b/net/sched/sch_csz.c	Tue Jan  6 06:37:39 2004
@@ -752,7 +752,7 @@
 
 	while ((tp = q->filter_list) != NULL) {
 		q->filter_list = tp->next;
-		tp->ops->destroy(tp);
+		tcf_destroy(tp);
 	}
 }
 
diff -Nru a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
--- a/net/sched/sch_dsmark.c	Tue Jan  6 06:37:39 2004
+++ b/net/sched/sch_dsmark.c	Tue Jan  6 06:37:39 2004
@@ -378,7 +378,7 @@
 	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;
diff -Nru a/net/sched/sch_htb.c b/net/sched/sch_htb.c
--- a/net/sched/sch_htb.c	Tue Jan  6 06:37:39 2004
+++ b/net/sched/sch_htb.c	Tue Jan  6 06:37:39 2004
@@ -1338,7 +1338,7 @@
 
 	while ((tp = *fl) != NULL) {
 		*fl = tp->next;
-		tp->ops->destroy(tp);
+		tcf_destroy(tp);
 	}
 }
 
diff -Nru a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
--- a/net/sched/sch_ingress.c	Tue Jan  6 06:37:39 2004
+++ b/net/sched/sch_ingress.c	Tue Jan  6 06:37:39 2004
@@ -292,7 +292,7 @@
 	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;
diff -Nru a/net/sched/sch_prio.c b/net/sched/sch_prio.c
--- a/net/sched/sch_prio.c	Tue Jan  6 06:37:39 2004
+++ b/net/sched/sch_prio.c	Tue Jan  6 06:37:39 2004
@@ -162,7 +162,7 @@
 
 	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++) {
