kasan:fix bug if kasan_mem_to_shadow mod size is 0 just return

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-01-16 16:47:04 +08:00 committed by Xiang Xiao
parent 745611f800
commit e26e1ab2ab

View File

@ -149,7 +149,7 @@ static FAR uintptr_t *kasan_mem_to_shadow(FAR const void *ptr, size_t size,
size_t mod; size_t mod;
size_t i; size_t i;
if (g_region_init != KASAN_INIT_VALUE || size == 0) if (g_region_init != KASAN_INIT_VALUE)
{ {
return NULL; return NULL;
} }
@ -168,6 +168,11 @@ static FAR uintptr_t *kasan_mem_to_shadow(FAR const void *ptr, size_t size,
} }
mod = size % KASAN_SHADOW_SCALE; mod = size % KASAN_SHADOW_SCALE;
if (mod == 0)
{
return NULL;
}
addr += mul * KASAN_SHADOW_SCALE; addr += mul * KASAN_SHADOW_SCALE;
size = mod; size = mod;
} }