Subject: [PATCH 2.6 1/7]: Fix module leak in tc_ctl_tfilter error path

From: Patrick McHardy <[email-masked]>
Date: Sun, 03 Oct 2004 23:12:48 +0200

When tp_ops->init fails we leak a module reference.

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/10/03 20:25:10+02:00 [email-masked] 
#   [NET_SCHED]: Fix module leak in tc_ctl_tfilter error path
#   
#   Signed-off-by: Patrick McHardy <[email-masked]>
# 
# net/sched/cls_api.c
#   2004/10/03 20:24:47+02:00 [email-masked] +6 -2
#   [NET_SCHED]: Fix module leak in tc_ctl_tfilter error path
#   
#   Signed-off-by: Patrick McHardy <[email-masked]>
# 
diff -Nru a/net/sched/cls_api.c b/net/sched/cls_api.c
--- a/net/sched/cls_api.c	2004-10-03 22:18:04 +02:00
+++ b/net/sched/cls_api.c	2004-10-03 22:18:04 +02:00
@@ -231,8 +231,12 @@
 		tp->classify = tp_ops->classify;
 		tp->classid = parent;
 		err = -EBUSY;
-		if (!try_module_get(tp_ops->owner) ||
-		    (err = tp_ops->init(tp)) != 0) {
+		if (!try_module_get(tp_ops->owner)) {
+			kfree(tp);
+			goto errout;
+		}
+		if ((err = tp_ops->init(tp)) != 0) {
+			module_put(tp_ops->owner);
 			kfree(tp);
 			goto errout;
 		}