lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1605687308-57318-1-git-send-email-tiantao6@hisilicon.com>
Date:   Wed, 18 Nov 2020 16:15:08 +0800
From:   Tian Tao <tiantao6@...ilicon.com>
To:     <davem@...emloft.net>, <kuba@...nel.org>, <linmiaohe@...wei.com>,
        <martin.varghese@...ia.com>, <pshelar@....org>,
        <pabeni@...hat.com>, <fw@...len.de>, <viro@...iv.linux.org.uk>,
        <gnault@...hat.com>, <steffen.klassert@...unet.com>,
        <kyk.segfault@...il.com>, <netdev@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH] net/core: use xx_zalloc instead xx_alloc and memset

use kmem_cache_zalloc instead kmem_cache_alloc and memset.

Signed-off-by: Tian Tao <tiantao6@...ilicon.com>
---
 net/core/skbuff.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index c9a5a3c..3449c1c 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -313,12 +313,10 @@ struct sk_buff *__build_skb(void *data, unsigned int frag_size)
 {
 	struct sk_buff *skb;
 
-	skb = kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC);
+	skb = kmem_cache_zalloc(skbuff_head_cache, GFP_ATOMIC);
 	if (unlikely(!skb))
 		return NULL;
 
-	memset(skb, 0, offsetof(struct sk_buff, tail));
-
 	return __build_skb_around(skb, data, frag_size);
 }
 
@@ -6170,12 +6168,10 @@ static void *skb_ext_get_ptr(struct skb_ext *ext, enum skb_ext_id id)
  */
 struct skb_ext *__skb_ext_alloc(gfp_t flags)
 {
-	struct skb_ext *new = kmem_cache_alloc(skbuff_ext_cache, flags);
+	struct skb_ext *new = kmem_cache_zalloc(skbuff_ext_cache, flags);
 
-	if (new) {
-		memset(new->offset, 0, sizeof(new->offset));
+	if (new)
 		refcount_set(&new->refcnt, 1);
-	}
 
 	return new;
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ