Commit 974f80e9 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[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.
parent 334cac53
...@@ -81,7 +81,12 @@ static inline int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, struct ...@@ -81,7 +81,12 @@ static inline int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, struct
return -1; 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 register_tcf_proto_ops(struct tcf_proto_ops *ops);
extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops); extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
......
...@@ -247,10 +247,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg) ...@@ -247,10 +247,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
*back = tp->next; *back = tp->next;
spin_unlock_bh(&dev->queue_lock); spin_unlock_bh(&dev->queue_lock);
write_unlock(&qdisc_tree_lock); write_unlock(&qdisc_tree_lock);
tcf_destroy(tp);
tp->ops->destroy(tp);
module_put(tp->ops->owner);
kfree(tp);
err = 0; err = 0;
goto errout; goto errout;
} }
......
...@@ -162,7 +162,7 @@ static void destroy_filters(struct atm_flow_data *flow) ...@@ -162,7 +162,7 @@ static void destroy_filters(struct atm_flow_data *flow)
while ((filter = flow->filter_list)) { while ((filter = flow->filter_list)) {
DPRINTK("destroy_filters: destroying filter %p\n",filter); DPRINTK("destroy_filters: destroying filter %p\n",filter);
flow->filter_list = filter->next; flow->filter_list = filter->next;
filter->ops->destroy(filter); tcf_destroy(filter);
} }
} }
......
...@@ -1705,7 +1705,7 @@ static void cbq_destroy_filters(struct cbq_class *cl) ...@@ -1705,7 +1705,7 @@ static void cbq_destroy_filters(struct cbq_class *cl)
while ((tp = cl->filter_list) != NULL) { while ((tp = cl->filter_list) != NULL) {
cl->filter_list = tp->next; cl->filter_list = tp->next;
tp->ops->destroy(tp); tcf_destroy(tp);
} }
} }
......
...@@ -752,7 +752,7 @@ csz_destroy(struct Qdisc* sch) ...@@ -752,7 +752,7 @@ csz_destroy(struct Qdisc* sch)
while ((tp = q->filter_list) != NULL) { while ((tp = q->filter_list) != NULL) {
q->filter_list = tp->next; q->filter_list = tp->next;
tp->ops->destroy(tp); tcf_destroy(tp);
} }
} }
......
...@@ -378,7 +378,7 @@ static void dsmark_destroy(struct Qdisc *sch) ...@@ -378,7 +378,7 @@ static void dsmark_destroy(struct Qdisc *sch)
while (p->filter_list) { while (p->filter_list) {
tp = p->filter_list; tp = p->filter_list;
p->filter_list = tp->next; p->filter_list = tp->next;
tp->ops->destroy(tp); tcf_destroy(tp);
} }
qdisc_destroy(p->q); qdisc_destroy(p->q);
p->q = &noop_qdisc; p->q = &noop_qdisc;
......
...@@ -1338,7 +1338,7 @@ static void htb_destroy_filters(struct tcf_proto **fl) ...@@ -1338,7 +1338,7 @@ static void htb_destroy_filters(struct tcf_proto **fl)
while ((tp = *fl) != NULL) { while ((tp = *fl) != NULL) {
*fl = tp->next; *fl = tp->next;
tp->ops->destroy(tp); tcf_destroy(tp);
} }
} }
......
...@@ -292,7 +292,7 @@ static void ingress_destroy(struct Qdisc *sch) ...@@ -292,7 +292,7 @@ static void ingress_destroy(struct Qdisc *sch)
while (p->filter_list) { while (p->filter_list) {
tp = p->filter_list; tp = p->filter_list;
p->filter_list = tp->next; p->filter_list = tp->next;
tp->ops->destroy(tp); tcf_destroy(tp);
} }
memset(p, 0, sizeof(*p)); memset(p, 0, sizeof(*p));
p->filter_list = NULL; p->filter_list = NULL;
......
...@@ -162,7 +162,7 @@ prio_destroy(struct Qdisc* sch) ...@@ -162,7 +162,7 @@ prio_destroy(struct Qdisc* sch)
while ((tp = q->filter_list) != NULL) { while ((tp = q->filter_list) != NULL) {
q->filter_list = tp->next; q->filter_list = tp->next;
tp->ops->destroy(tp); tcf_destroy(tp);
} }
for (prio=0; prio<q->bands; prio++) { for (prio=0; prio<q->bands; prio++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment