
From: Chenghai Huang <huangchenghai2@huawei.com> After a failure message is returned due to a calloc exception, the mp-ref count must be decreased by 1. Otherwise, an infinite loop occurs when the process invokes the mp command to destroy the process and cannot exit. Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> --- wd_mempool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wd_mempool.c b/wd_mempool.c index cb8c80b..ed107d1 100644 --- a/wd_mempool.c +++ b/wd_mempool.c @@ -573,7 +573,7 @@ handle_t wd_blockpool_create(handle_t mempool, size_t block_size, bp = calloc(1, sizeof(struct blkpool)); if (!bp) { WD_ERR("failed to alloc memory for blkpool!\n"); - return (handle_t)(-WD_ENOMEM); + goto err_sub_ref; } bp->top = block_num; @@ -597,6 +597,7 @@ err_free_mem: free_mem_to_mempool(bp); err_free_bp: free(bp); +err_sub_ref: wd_atomic_sub(&mp->ref, 1); return (handle_t)(-WD_ENOMEM); } -- 2.30.0