55 lines
1.5 KiB
Diff
55 lines
1.5 KiB
Diff
From a30caaa94e0cc806a4ee64031c300c630f758cd6 Mon Sep 17 00:00:00 2001
|
|
From: Weili Qian <qianweili@huawei.com>
|
|
Date: Tue, 20 Aug 2024 11:39:27 +0800
|
|
Subject: [PATCH 15/16] uadk: check calloc return value
|
|
|
|
Added the check of the return value of calloc.
|
|
|
|
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
|
Signed-off-by: Qi Tao <taoqi10@huawei.com>
|
|
---
|
|
wd_util.c | 10 +++++++---
|
|
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/wd_util.c b/wd_util.c
|
|
index 5350f84..8d362d7 100644
|
|
--- a/wd_util.c
|
|
+++ b/wd_util.c
|
|
@@ -2632,10 +2632,15 @@ static int wd_alg_ce_ctx_init(struct wd_init_attrs *attrs)
|
|
ctx_config->ctx_num = 1;
|
|
ctx_config->ctxs = calloc(ctx_config->ctx_num, sizeof(struct wd_ctx));
|
|
if (!ctx_config->ctxs) {
|
|
- return -WD_ENOMEM;
|
|
WD_ERR("failed to alloc ctxs!\n");
|
|
+ return -WD_ENOMEM;
|
|
}
|
|
+
|
|
ctx_config->ctxs[0].ctx = (handle_t)calloc(1, sizeof(struct wd_ce_ctx));
|
|
+ if (!ctx_config->ctxs[0].ctx) {
|
|
+ free(ctx_config->ctxs);
|
|
+ return -WD_ENOMEM;
|
|
+ }
|
|
|
|
return WD_SUCCESS;
|
|
}
|
|
@@ -2719,7 +2724,7 @@ int wd_alg_attrs_init(struct wd_init_attrs *attrs)
|
|
char alg_type[CRYPTO_MAX_ALG_NAME];
|
|
int driver_type = UADK_ALG_HW;
|
|
char *alg = attrs->alg;
|
|
- int ret = 0;
|
|
+ int ret = -WD_EINVAL;
|
|
|
|
if (!attrs->ctx_params)
|
|
return -WD_EINVAL;
|
|
@@ -2801,7 +2806,6 @@ int wd_alg_attrs_init(struct wd_init_attrs *attrs)
|
|
numa_max_node() + 1, alg_poll_func);
|
|
if (!alg_sched) {
|
|
WD_ERR("fail to instance scheduler\n");
|
|
- ret = -WD_EINVAL;
|
|
goto out_ctx_config;
|
|
}
|
|
attrs->sched = alg_sched;
|
|
--
|
|
2.25.1
|
|
|