Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c6a1e615d1ba942b9e783079d53f741e4a8e1c89
Commit:     c6a1e615d1ba942b9e783079d53f741e4a8e1c89
Parent:     0661cca9c216322e77dca7f47df107c02ce4e70c
Author:     Patrick McHardy <[EMAIL PROTECTED]>
AuthorDate: Wed Mar 14 16:39:07 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Wed Apr 25 22:25:43 2007 -0700

    [NETFILTER]: nf_conntrack: simplify l4 protocol array allocation
    
    The retrying after an allocation failure is not necessary anymore
    since we're holding the mutex the entire time, for the same
    reason the double allocation race can't happen anymore.
    
    Signed-off-by: Patrick McHardy <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/netfilter/nf_conntrack_proto.c |   37 +++++++++++------------------------
 1 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/net/netfilter/nf_conntrack_proto.c 
b/net/netfilter/nf_conntrack_proto.c
index 5097254..e4aad20 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -281,47 +281,34 @@ int nf_conntrack_l4proto_register(struct 
nf_conntrack_l4proto *l4proto)
                return -EBUSY;
 
        mutex_lock(&nf_ct_proto_mutex);
-retry:
-       if (nf_ct_protos[l4proto->l3proto]) {
-               if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto]
-                               != &nf_conntrack_l4proto_generic) {
-                       ret = -EBUSY;
-                       goto out_unlock;
-               }
-       } else {
+       if (!nf_ct_protos[l4proto->l3proto]) {
                /* l3proto may be loaded latter. */
                struct nf_conntrack_l4proto **proto_array;
                int i;
 
-               proto_array = (struct nf_conntrack_l4proto **)
-                               kmalloc(MAX_NF_CT_PROTO *
-                                        sizeof(struct nf_conntrack_l4proto *),
-                                       GFP_KERNEL);
+               proto_array = kmalloc(MAX_NF_CT_PROTO *
+                                     sizeof(struct nf_conntrack_l4proto *),
+                                     GFP_KERNEL);
                if (proto_array == NULL) {
                        ret = -ENOMEM;
                        goto out_unlock;
                }
+
                for (i = 0; i < MAX_NF_CT_PROTO; i++)
                        proto_array[i] = &nf_conntrack_l4proto_generic;
-
-               if (nf_ct_protos[l4proto->l3proto])
-                       /* bad timing, but no problem */
-                       kfree(proto_array);
-               else
-                       nf_ct_protos[l4proto->l3proto] = proto_array;
-
-               /*
-                * Just once because array is never freed until unloading
-                * nf_conntrack.ko
-                */
-               goto retry;
+               nf_ct_protos[l4proto->l3proto] = proto_array;
+       } else if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] !=
+                                       &nf_conntrack_l4proto_generic) {
+               ret = -EBUSY;
+               goto out_unlock;
        }
 
        ret = nf_ct_l4proto_register_sysctl(l4proto);
        if (ret < 0)
                goto out_unlock;
 
-       rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], 
l4proto);
+       rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
+                          l4proto);
 
 out_unlock:
        mutex_unlock(&nf_ct_proto_mutex);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to