Skip to content

Commit

Permalink
[NET]: Auto-zero the allocated sock object
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Nov 1, 2007
1 parent c308c1b commit 3f0666e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3f0666e

Please sign in to comment.