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

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit efc29f10b278144dcce1449edb93c150968bd05c
Author: Bowen Wang <[email protected]>
AuthorDate: Fri Nov 20 02:56:53 2026 +0800

    mm/mempool: free the whole multiple pool on init failure
    
    mempool_multiple_init() allocates one block holding both the
    mempool_multiple_s and the pools array, but the err_with_pools path hands
    the interior pools pointer to mempool_multiple_free_chunk():
    
      err_with_pools:
        while (--i >= 0)
          {
            mempool_deinit(pools + i);
          }
    
        mempool_multiple_free_chunk(mpool, pools);
        return NULL;
    
    With chunksize < expandsize free_chunk() calls free() on that interior
    pointer; otherwise it takes mpool->lock, which is only initialized on the
    success path, and frees nothing, because the chunk queue is empty.
    
    Free the block that was allocated, the same way
    mempool_multiple_deinit() does.
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 mm/mempool/mempool_multiple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mempool/mempool_multiple.c b/mm/mempool/mempool_multiple.c
index 72acbb1f55a..b4bbfb7bd15 100644
--- a/mm/mempool/mempool_multiple.c
+++ b/mm/mempool/mempool_multiple.c
@@ -512,7 +512,7 @@ err_with_pools:
       mempool_deinit(pools + i);
     }
 
-  mempool_multiple_free_chunk(mpool, pools);
+  free(arg, mpool);
   return NULL;
 }
 

Reply via email to