diff options
| author | Pavel Emelyanov <xemul@openvz.org> | 2007-11-01 03:34:42 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2007-11-01 03:34:42 -0400 |
| commit | 3f0666ee3039443fa7b7cf436dd16ce0dd8e3f95 (patch) | |
| tree | 2d2eb78ad66f312fc85ab9c6a009207535d736ed | |
| parent | c308c1b20e2eb7b13f200a7c18b3f23561318367 (diff) | |
[NET]: Auto-zero the allocated sock object
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>
| -rw-r--r-- | net/core/sock.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 6ee2ed104a83..b66f607fcb96 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
| @@ -908,10 +908,12 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, | |||
| 908 | { | 908 | { |
| 909 | struct sock *sk; | 909 | struct sock *sk; |
| 910 | 910 | ||
| 911 | if (zero_it) | ||
| 912 | priority |= __GFP_ZERO; | ||
| 913 | |||
| 911 | sk = sk_prot_alloc(prot, priority); | 914 | sk = sk_prot_alloc(prot, priority); |
| 912 | if (sk) { | 915 | if (sk) { |
| 913 | if (zero_it) { | 916 | if (zero_it) { |
| 914 | memset(sk, 0, prot->obj_size); | ||
| 915 | sk->sk_family = family; | 917 | sk->sk_family = family; |
| 916 | /* | 918 | /* |
| 917 | * See comment in struct sock definition to understand | 919 | * See comment in struct sock definition to understand |
