From: Chenghai Huang huangchenghai2@huawei.com
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);