[NET]: Auto-zero the allocated sock object
authorPavel Emelyanov <xemul@openvz.org>
Thu, 1 Nov 2007 07:34:42 +0000 (00:34 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 1 Nov 2007 07:34:42 +0000 (00:34 -0700)
We have a __GFP_ZERO flag that allocates a zeroed chunk of memory.
Use it in the sk_alloc() and avoid a hand-made memset().

This is a temporary patch that will help us in the nearest future :)

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock.c

index 6ee2ed104a83329bf06d3137af078244f73cdcc4..b66f607fcb961ec9e803fe18abb1f9bee8132f88 100644 (file)
@@ -908,10 +908,12 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
 {
        struct sock *sk;
 
+       if (zero_it)
+               priority |= __GFP_ZERO;
+
        sk = sk_prot_alloc(prot, priority);
        if (sk) {
                if (zero_it) {
-                       memset(sk, 0, prot->obj_size);
                        sk->sk_family = family;
                        /*
                         * See comment in struct sock definition to understand