* [PATCH] lib: Use kzalloc() instead of kmalloc() with flag GFP_ZERO.
@ 2020-02-12 9:53 Yi Wang
2020-02-12 9:56 ` Alexander Potapenko
0 siblings, 1 reply; 3+ messages in thread
From: Yi Wang @ 2020-02-12 9:53 UTC (permalink / raw)
To: aryabinin
Cc: glider, dvyukov, kasan-dev, linux-kernel, xue.zhihong, wang.yi59,
wang.liang82, Huang Zijiang
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.
Change in v2:
add indation
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 328d33b..79be158 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -599,7 +599,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;
@@ -614,7 +614,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;
@@ -629,7 +629,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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib: Use kzalloc() instead of kmalloc() with flag GFP_ZERO.
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
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Potapenko @ 2020-02-12 9:56 UTC (permalink / raw)
To: Yi Wang
Cc: Andrey Ryabinin, Dmitriy Vyukov, kasan-dev, LKML, xue.zhihong,
wang.liang82, Huang Zijiang
On Wed, Feb 12, 2020 at 10:54 AM Yi Wang <wang.yi59@zte.com.cn> wrote:
>
> 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.
>
> Change in v2:
> add indation
>
> Signed-off-by: Huang Zijiang <huang.zijiang@zte.com.cn>
> Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Reviewed-by: Alexander Potapenko <glider@google.com>
> ---
> 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 328d33b..79be158 100644
> --- a/lib/test_kasan.c
> +++ b/lib/test_kasan.c
> @@ -599,7 +599,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;
>
> @@ -614,7 +614,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;
>
> @@ -629,7 +629,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
>
> --
> You received this message because you are subscribed to the Google Groups "kasan-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/1581501228-5393-1-git-send-email-wang.yi59%40zte.com.cn.
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] lib: Use kzalloc() instead of kmalloc() with flag GFP_ZERO.
@ 2019-12-23 1:49 Yi Wang
0 siblings, 0 replies; 3+ messages in thread
From: Yi Wang @ 2019-12-23 1:49 UTC (permalink / raw)
To: aryabinin
Cc: glider, dvyukov, kasan-dev, linux-kernel, xue.zhihong, wang.yi59,
up2wing, wang.liang82, Huang Zijiang
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-12 9:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
-- strict thread matches above, loose matches on Subject: below --
2019-12-23 1:49 Yi Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.