linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yi Wang <wang.yi59@zte.com.cn>
To: aryabinin@virtuozzo.com
Cc: glider@google.com, dvyukov@google.com,
	kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org,
	xue.zhihong@zte.com.cn, wang.yi59@zte.com.cn, up2wing@gmail.com,
	wang.liang82@zte.com.cn, Huang Zijiang <huang.zijiang@zte.com.cn>
Subject: [PATCH] lib: Use kzalloc() instead of kmalloc() with flag GFP_ZERO.
Date: Mon, 23 Dec 2019 09:49:34 +0800	[thread overview]
Message-ID: <1577065774-25142-1-git-send-email-wang.yi59@zte.com.cn> (raw)

From: Huang Zijiang <huang.zijiang@zte.com.cn>

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

Signed-off-by: Huang Zijiang <huang.zijiang@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
---
 lib/test_kasan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 05686c8..ff5d21e 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -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;

-- 
1.9.1


             reply	other threads:[~2019-12-23  1:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-23  1:49 Yi Wang [this message]
2020-02-12  9:53 [PATCH] lib: Use kzalloc() instead of kmalloc() with flag GFP_ZERO Yi Wang
2020-02-12  9:56 ` Alexander Potapenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1577065774-25142-1-git-send-email-wang.yi59@zte.com.cn \
    --to=wang.yi59@zte.com.cn \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=huang.zijiang@zte.com.cn \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=up2wing@gmail.com \
    --cc=wang.liang82@zte.com.cn \
    --cc=xue.zhihong@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).