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 <wangjianyu3@xiaomi.com>
This commit is contained in:
wangjianyu3 2024-01-23 22:49:08 +08:00 committed by Xiang Xiao
parent 5d0ffdf44e
commit fa5d843aa9
1 changed files with 5 additions and 0 deletions

View File

@ -233,6 +233,11 @@ static void kasan_set_poison(FAR const void *addr, size_t size,
uintptr_t mask; uintptr_t mask;
int flags; int flags;
if (size == 0)
{
return;
}
flags = spin_lock_irqsave(&g_lock); flags = spin_lock_irqsave(&g_lock);
p = kasan_mem_to_shadow(addr, size, &bit); p = kasan_mem_to_shadow(addr, size, &bit);