From fa5d843aa9a57028b3ae70358027e2d8d29126bd Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Tue, 23 Jan 2024 22:49:08 +0800 Subject: [PATCH] assert in kasan_set_poison() if `size` is zero e.g. mm_realloc() => kasan_poison() => kasan_set_poison() _assert: Assertion failed p != ((void*)0): at file: kasan/kasan.c:239 task: nsh_main process: nsh_main 0x4402caa5 Signed-off-by: wangjianyu3 --- mm/kasan/kasan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c index d29d549275..971b5e5114 100644 --- a/mm/kasan/kasan.c +++ b/mm/kasan/kasan.c @@ -233,6 +233,11 @@ static void kasan_set_poison(FAR const void *addr, size_t size, uintptr_t mask; int flags; + if (size == 0) + { + return; + } + flags = spin_lock_irqsave(&g_lock); p = kasan_mem_to_shadow(addr, size, &bit);