[PATCH 3/9] tlsf: ensure malloc pool is aligned
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Oct 4 08:54:01 PDT 2022
The struct control_t describing a pool is allocated at its very start
and then directly followed by the first block. To ensure the first block
is suitably aligned, align_up the size in tlsf_size(). So far, TLSF on
32-bit and 64-bit happened to be aligned, so this introduces no
functional change just yet. With upcoming changes to the block header to
increase alignment on 32-bit systems, this realignment will become required.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/tlsf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/tlsf.c b/common/tlsf.c
index 8dbb41077cad..f8892dafbb7f 100644
--- a/common/tlsf.c
+++ b/common/tlsf.c
@@ -770,11 +770,11 @@ int tlsf_check_pool(pool_t pool)
/*
** Size of the TLSF structures in a given memory block passed to
-** tlsf_create, equal to the size of a control_t
+** tlsf_create, equal to aligned size of a control_t
*/
size_t tlsf_size(void)
{
- return sizeof(control_t);
+ return align_up(sizeof(control_t), ALIGN_SIZE);
}
size_t tlsf_align_size(void)
--
2.30.2
More information about the barebox
mailing list