lx_emul: natural alignment of power-of-two kmalloc

This commit is contained in:
Christian Helmuth 2023-08-21 14:35:05 +02:00
parent 62492f3cd2
commit e337f2cb0f

View File

@ -46,6 +46,9 @@ void * __kmalloc(size_t size, gfp_t flags)
/* for page-rounded sizes use page-alignment */
if ((size % PAGE_SIZE) == 0) align = PAGE_SIZE;
/* guarantee natural alignment for power-of-two kmalloc (see mm/slab_common.c) */
if (is_power_of_2(size)) align = max_t(unsigned long, align, size);
return lx_emul_mem_alloc_aligned(size, align);
}