netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: jamal <hadi@cyberus.ca>
Cc: Maillist netdev <netdev@oss.sgi.com>
Subject: [PATCH PKT_SCHED 18/22]: ipt action: fix module refcnt underflow/mem leaks in tcf_ipt_cleanup
Date: Mon, 10 Jan 2005 20:38:13 +0100	[thread overview]
Message-ID: <41E2D9A5.4070006@trash.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 18.diff --]
[-- Type: text/x-patch, Size: 1654 bytes --]

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/01/10 03:28:14+01:00 kaber@coreworks.de 
#   [PKT_SCHED]: ipt action: fix module refcnt underflow/mem leaks in tcf_ipt_cleanup
#   
#   Signed-off-by: Patrick McHardy <kaber@trash.net>
# 
# net/sched/ipt.c
#   2005/01/10 03:28:07+01:00 kaber@coreworks.de +22 -10
#   [PKT_SCHED]: ipt action: fix module refcnt underflow/mem leaks in tcf_ipt_cleanup
#   
#   Signed-off-by: Patrick McHardy <kaber@trash.net>
# 
diff -Nru a/net/sched/ipt.c b/net/sched/ipt.c
--- a/net/sched/ipt.c	2005-01-10 06:23:03 +01:00
+++ b/net/sched/ipt.c	2005-01-10 06:23:03 +01:00
@@ -92,6 +92,25 @@
 }
 
 static int
+tcf_ipt_release(struct tcf_ipt *p, int bind)
+{
+	int ret = 0;
+	if (p) {
+		if (bind)
+			p->bindcnt--;
+		p->refcnt--;
+		if (p->bindcnt <= 0 && p->refcnt <= 0) {
+			ipt_destroy_target(p->t);
+			kfree(p->tname);
+			kfree(p->t);
+			tcf_hash_destroy(p);
+			ret = ACT_P_DELETED;
+		}
+	}
+	return ret;
+}
+
+static int
 tcf_ipt_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,
              int ovr, int bind)
 {
@@ -129,7 +148,7 @@
 		ret = ACT_P_CREATED;
 	} else {
 		if (!ovr) {
-			tcf_hash_release(p, bind);
+			tcf_ipt_release(p, bind);
 			return -EEXIST;
 		}
 	}
@@ -178,15 +197,8 @@
 static int
 tcf_ipt_cleanup(struct tc_action *a, int bind)
 {
-	struct tcf_ipt *p = PRIV(a,ipt);
-
-	if (NULL != p) {
-		struct ipt_entry_target *t = p->t;
-		if (t && t->u.kernel.target)
-			module_put(t->u.kernel.target->me);
-		return tcf_hash_release(p, bind);
-	}
-	return 0;
+	struct tcf_ipt *p = PRIV(a, ipt);
+	return tcf_ipt_release(p, bind);
 }
 
 static int

                 reply	other threads:[~2005-01-10 19:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41E2D9A5.4070006@trash.net \
    --to=kaber@trash.net \
    --cc=hadi@cyberus.ca \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).