Skip to content

Commit 1140bd0

Browse files
Nicolas Pitrenashif
authored andcommitted
mempool: properly use the inline free block bitmap
The free block bitmap uses either extra memory specified by a pointer in struct sys_mem_pool_lvl or the space occupied by that pointer directly if the bitmap length is small enough to fit it. But the test is wrong. the inline bitmap should be used if the number of required bits is smaller or _equal_ to the pointer size. Not doing so would wrongly bounce the free block bitmap to extra memory when the number of blocks is exactly 32, which is in disagreement with Z_MPOOL_LBIT_WORDS() that correctly returns 0 in that case. In theory that mean that this bug would causes an overflow of the free block bitmap whenever one level has exactly 32 blocks. But right now there is a separate bug fixed separately that over-sizes the extra block bitmap mitigating this bug. Signed-off-by: Nicolas Pitre <[email protected]>
1 parent cf5c22d commit 1140bd0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/os/mempool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void z_sys_mem_pool_base_init(struct sys_mem_pool_base *p)
104104

105105
sys_dlist_init(&p->levels[i].free_list);
106106

107-
if (nblocks < 32) {
107+
if (nblocks <= 32) {
108108
p->max_inline_level = i;
109109
} else {
110110
p->levels[i].bits_p = bits;

0 commit comments

Comments
 (0)