提交 3f0666ee 编写于 作者: P Pavel Emelyanov 提交者: David S. Miller

[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: NPavel Emelyanov <xemul@openvz.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c308c1b2
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册