-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mempool: make sure max block size isn't smaller than minimum allowed
If maxsize is smaller than _MPOOL_MINBLK, then Z_MPOOL_LVLS() will be 0. That means the loop in z_sys_mem_pool_base_init() that initializes the block free list for the nonexistent level 0 will corrupt whatever memory at the location the zero-sized struct sys_mem_pool_lvl array was located. And the corruption happens to be done with a perfectly legit memory pool block address which makes for really nasty bugs to solve. This is more likely on 64-bit systems due to _MPOOL_MINBLK being twice the size of 32-bit systems. Let's prevent that with a build-time assertion on maxsize when defining a memory pool, and adjust the affected test accordingly. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
- Loading branch information
1 parent
fc4ca92
commit ace11bb
Showing
3 changed files
with
3 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters