Skip to contentSkip to conversation

lib: Use kzalloc() instead of kmalloc() with flag GFP_ZERO.

PATCH New Yi Wang 1 participant 1 message Dec 23, 2019 Library code

lore
Share & tools
lore

Yi Wang

author
#0 lore raw

PATCH 1/1 lib: Use kzalloc() instead of kmalloc() with flag GFP_ZERO.

From: Huang Zijiang <[email protected]>

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

---
 lib/test_kasan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/test_kasan.c +3 -3
index 05686c8..ff5d21e 100644
@@ -598,7 +598,7 @@ static noinline void __init kasan_memchr(void)
     size_t size = 24;
 
     pr_info("out-of-bounds in memchr\n");
-    ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
+ptr = kzalloc(size, GFP_KERNEL);
     if (!ptr)
         return;
 
@@ -613,7 +613,7 @@ static noinline void __init kasan_memcmp(void)
     int arr[9];
 
     pr_info("out-of-bounds in memcmp\n");
-    ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
+ptr = kzalloc(size, GFP_KERNEL);
     if (!ptr)
         return;
 
@@ -628,7 +628,7 @@ static noinline void __init kasan_strings(void)
     size_t size = 24;
 
     pr_info("use-after-free in strchr\n");
-    ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
+ptr = kzalloc(size, GFP_KERNEL);
     if (!ptr)
         return;
 
Signature · 1 line
1.9.1