llext: clarify section map allocation size

Use an element size explicitly when calculating the array size and
use the calculated size for memset().

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2023-11-15 17:19:57 +01:00 committed by Anas Nashif
commit b5ce5012e2

View file

@ -761,7 +761,7 @@ static int do_llext_load(struct llext_loader *ldr, struct llext *ext,
ldr->sect_cnt = 0;
ext->sym_tab.sym_cnt = 0;
size_t sect_map_sz = ldr->hdr.e_shnum * sizeof(uint32_t);
size_t sect_map_sz = ldr->hdr.e_shnum * sizeof(ldr->sect_map[0]);
ldr->sect_map = k_heap_alloc(&llext_heap, sect_map_sz, K_NO_WAIT);
if (!ldr->sect_map) {
@ -769,7 +769,8 @@ static int do_llext_load(struct llext_loader *ldr, struct llext *ext,
ret = -ENOMEM;
goto out;
}
memset(ldr->sect_map, 0, ldr->hdr.e_shnum*sizeof(uint32_t));
memset(ldr->sect_map, 0, sect_map_sz);
ldr->sect_cnt = ldr->hdr.e_shnum;
ext->mem_size += sect_map_sz;