libwd/0097-uadk-fix-the-failure-process-bug.patch
2023-12-08 11:56:44 +08:00

40 lines
1.1 KiB
Diff

From 044afdf1f90573c3a44187f7759461f496bf7bf8 Mon Sep 17 00:00:00 2001
From: Qi Tao <taoqi10@huawei.com>
Date: Mon, 4 Dec 2023 17:18:43 +0800
Subject: [PATCH 097/114] uadk: fix the failure process bug
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.25.1