Skip to content

Commit 2c7d680

Browse files
pdunajgalak
authored andcommitted
lib: mempool: Return error if no block found
Return -ENOMEM if no block is available on any level. Fixes: #14504 Signed-off-by: Pawel Dunaj <[email protected]>
1 parent 94ae61f commit 2c7d680

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/os/mempool.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,14 @@ int z_sys_mem_pool_block_alloc(struct sys_mem_pool_base *p, size_t size,
299299
}
300300
pool_irq_unlock(p, key);
301301

302+
*data_p = data;
303+
304+
if (data == NULL) {
305+
return -ENOMEM;
306+
}
307+
302308
*level_p = alloc_l;
303309
*block_p = block_num(p, data, lsizes[alloc_l]);
304-
*data_p = data;
305310

306311
return 0;
307312
}

0 commit comments

Comments
 (0)