Skip to contentSkip to conversation

xfrm: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO.

PATCH In review Yi Wang 2 participants 2 messages Dec 23, 2019

Subsystems (3)
lore
Share & tools
lore

Yi Wang

author
#0 lore raw

PATCH 1/1 xfrm: Use kmem_cache_zalloc() instead of kmem_cache_alloc() with flag GFP_ZERO.

From: Huang Zijiang <[email protected]>

Use kmem_cache_zalloc instead of manually setting kmem_cache_alloc with flag GFP_ZERO since kzalloc sets allocated memory to zero.

---
 net/xfrm/xfrm_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/xfrm_state.c +1 -1
index a5dc319..adfa279 100644
@@ -612,7 +612,7 @@ struct xfrm_state *xfrm_state_alloc(struct net *net)
 {
     struct xfrm_state *x;
 
-    x = kmem_cache_alloc(xfrm_state_cache, GFP_ATOMIC | __GFP_ZERO);
+x = kmem_cache_zalloc(xfrm_state_cache, GFP_ATOMIC);
 
     if (x) {
         write_pnet(&x->xs_net, net);
Signature · 1 line
1.9.1
#1 lore raw

Hello!

Quoted 17 lines · Yi Wang

From: Huang Zijiang <[email protected]>

Use kmem_cache_zalloc instead of manually setting kmem_cache_alloc with flag GFP_ZERO since kzalloc sets allocated memory to zero.

---
  net/xfrm/xfrm_state.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/xfrm_state.c +0 -0
index a5dc319..adfa279 100644

net/xfrm/xfrm_state.c struct xfrm_state *xfrm_state_alloc(struct net *net) · line 615

Quoted 5 lines
net/xfrm/xfrm_state.c +1 -1
@@ -612,7 +612,7 @@ struct xfrm_state *xfrm_state_alloc(struct net *net)
  {
      struct xfrm_state *x;
 
-    x = kmem_cache_alloc(xfrm_state_cache, GFP_ATOMIC | __GFP_ZERO);
+x = kmem_cache_zalloc(xfrm_state_cache, GFP_ATOMIC);

You ate the indentation. :-)

[...]

MBR, Sergei