You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2022/06/15 06:18:49 UTC

[mynewt-core] branch master updated: mempool: Fix OS_MEMPOOL_SIZE when OS_MEMPOOL_GUARD is on

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new c356dc815 mempool: Fix OS_MEMPOOL_SIZE when OS_MEMPOOL_GUARD is on
c356dc815 is described below

commit c356dc815e1584fb6fa92789e23fd2daab8ee70d
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Tue Jun 14 15:11:14 2022 +0200

    mempool: Fix OS_MEMPOOL_SIZE when OS_MEMPOOL_GUARD is on
    
    OS_MEMPOOL_SIZE returned incorrect memory size for mpool buffer when
    OS_MEMPOOL_GUARD was enabled.
    OS_MEMPOOL_GUARD requires extra space between memory blocks and
    OS_MEMPOOL_SIZE (and OS_MEMPOOL_BYTES) returned values that did not
    include this extra space.
    During os_mempool_init_internal() memory outside expected buffer
    was clobbered.
---
 kernel/os/include/os/os_mempool.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/os/include/os/os_mempool.h b/kernel/os/include/os/os_mempool.h
index 1182798e2..ff6937388 100644
--- a/kernel/os/include/os/os_mempool.h
+++ b/kernel/os/include/os/os_mempool.h
@@ -176,7 +176,7 @@ typedef __uint128_t os_membuf_t;
 #else
 #error "Unhandled `OS_ALIGNMENT` for `os_membuf_t`"
 #endif /* OS_ALIGNMENT == * */
-#define OS_MEMPOOL_SIZE(n,blksize)      ((((blksize) + ((OS_ALIGNMENT)-1)) / (OS_ALIGNMENT)) * (n))
+#define OS_MEMPOOL_SIZE(n,blksize)      (((OS_MEMPOOL_BLOCK_SZ(blksize) + ((OS_ALIGNMENT)-1)) / (OS_ALIGNMENT)) * (n))
 
 /** Calculates the number of bytes required to initialize a memory pool. */
 #define OS_MEMPOOL_BYTES(n,blksize)     \