netdev
[Top] [All Lists]

[PATCH PKT_SCHED 18/22]: ipt action: fix module refcnt underflow/mem lea

To: jamal <hadi@xxxxxxxxxx>
Subject: [PATCH PKT_SCHED 18/22]: ipt action: fix module refcnt underflow/mem leaks in tcf_ipt_cleanup
From: Patrick McHardy <kaber@xxxxxxxxx>
Date: Mon, 10 Jan 2005 20:38:13 +0100
Cc: Maillist netdev <netdev@xxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.3) Gecko/20041008 Debian/1.7.3-5

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/01/10 03:28:14+01:00 kaber@xxxxxxxxxxxx 
#   [PKT_SCHED]: ipt action: fix module refcnt underflow/mem leaks in 
tcf_ipt_cleanup
#   
#   Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
# 
# net/sched/ipt.c
#   2005/01/10 03:28:07+01:00 kaber@xxxxxxxxxxxx +22 -10
#   [PKT_SCHED]: ipt action: fix module refcnt underflow/mem leaks in 
tcf_ipt_cleanup
#   
#   Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
# 
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
<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH PKT_SCHED 18/22]: ipt action: fix module refcnt underflow/mem leaks in tcf_ipt_cleanup, Patrick McHardy <=