libwd/0102-uadk-v1-fix-wd_rng-resource-release-bug.patch
2023-12-08 11:56:44 +08:00

41 lines
1.1 KiB
Diff

From f99c4bfe4aec8110043bd88df0f52b47ed8e05e8 Mon Sep 17 00:00:00 2001
From: Qi Tao <taoqi10@huawei.com>
Date: Mon, 4 Dec 2023 17:30:23 +0800
Subject: [PATCH 102/114] uadk v1: fix wd_rng resource release bug
Before wd_free_id and ctx_num are released, check
whether ctx_num is less than or equal to 0 to
avoid repeated release.
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
v1/wd_rng.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/v1/wd_rng.c b/v1/wd_rng.c
index 927665f..24a4b7a 100644
--- a/v1/wd_rng.c
+++ b/v1/wd_rng.c
@@ -144,14 +144,14 @@ void wcrypto_del_rng_ctx(void *ctx)
wd_uninit_cookie_pool(&cx->pool);
wd_spinlock(&qinfo->qlock);
- wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, cx->ctx_id - 1,
- WD_MAX_CTX_NUM);
- qinfo->ctx_num--;
- if (qinfo->ctx_num < 0) {
+ if (qinfo->ctx_num <= 0) {
wd_unspinlock(&qinfo->qlock);
WD_ERR("repeat delete trng ctx!\n");
return;
}
+ qinfo->ctx_num--;
+ wd_free_id(qinfo->ctx_id, WD_MAX_CTX_NUM, cx->ctx_id - 1,
+ WD_MAX_CTX_NUM);
wd_unspinlock(&qinfo->qlock);
free(ctx);
--
2.25.1