*** BLURB HERE ***
Qi Tao (2): acc/uadk: fix queue configuration parameter error. acc/uadk: fix double-free error
wd.c | 3 --- wd_aead.c | 2 +- wd_agg.c | 4 ++-- wd_cipher.c | 4 ++-- wd_comp.c | 2 +- wd_dh.c | 6 ++++-- wd_digest.c | 4 ++-- wd_ecc.c | 6 ++++-- wd_rsa.c | 6 ++++-- wd_util.c | 4 ++++ 10 files changed, 24 insertions(+), 17 deletions(-)
When executing an asynchronous task, the scheduler may incorrectly specify a synchronous queue. This will cause an error in the queue configuration parameters and result in a segment error. In wd_get_msg_from_pool(), msg_num == 0 indicates that the asynchronous task scheduler is executed but the synchronous queue is specified.Therefore, when msg_num == 0 is detected in this function, the program needs to return an exception immediately to avoid errors.
Signed-off-by: Qi Tao taoqi10@huawei.com --- wd_aead.c | 2 +- wd_agg.c | 4 ++-- wd_cipher.c | 4 ++-- wd_comp.c | 2 +- wd_dh.c | 6 ++++-- wd_digest.c | 4 ++-- wd_ecc.c | 6 ++++-- wd_rsa.c | 6 ++++-- wd_util.c | 4 ++++ 9 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/wd_aead.c b/wd_aead.c index a4bb5b22..7eb217aa 100644 --- a/wd_aead.c +++ b/wd_aead.c @@ -797,7 +797,7 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req) idx, (void **)&msg); if (unlikely(msg_id < 0)) { WD_ERR("failed to get msg from pool!\n"); - return -WD_EBUSY; + return msg_id; }
fill_request_msg(msg, req, sess); diff --git a/wd_agg.c b/wd_agg.c index 7a16cfe6..e0d7bbf4 100644 --- a/wd_agg.c +++ b/wd_agg.c @@ -1193,8 +1193,8 @@ static int wd_agg_async_job(struct wd_agg_sess *sess, struct wd_agg_req *req, bo ctx = config->ctxs + idx; msg_id = wd_get_msg_from_pool(&wd_agg_setting.pool, idx, (void **)&msg); if (unlikely(msg_id < 0)) { - WD_ERR("busy, failed to get agg msg from pool!\n"); - return -WD_EBUSY; + WD_ERR("failed to get agg msg from pool!\n"); + return msg_id; }
if (is_input) diff --git a/wd_cipher.c b/wd_cipher.c index 51302531..a8330741 100644 --- a/wd_cipher.c +++ b/wd_cipher.c @@ -757,8 +757,8 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req) msg_id = wd_get_msg_from_pool(&wd_cipher_setting.pool, idx, (void **)&msg); if (unlikely(msg_id < 0)) { - WD_ERR("busy, failed to get msg from pool!\n"); - return -WD_EBUSY; + WD_ERR("failed to get msg from pool!\n"); + return msg_id; }
fill_request_msg(msg, req, sess); diff --git a/wd_comp.c b/wd_comp.c index 98f9e7d4..9d25ce58 100644 --- a/wd_comp.c +++ b/wd_comp.c @@ -864,7 +864,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req) tag = wd_get_msg_from_pool(&wd_comp_setting.pool, idx, (void **)&msg); if (unlikely(tag < 0)) { WD_ERR("failed to get msg from pool!\n"); - return -WD_EBUSY; + return tag; } fill_comp_msg(sess, msg, req); msg->tag = tag; diff --git a/wd_dh.c b/wd_dh.c index e84f2bf8..2e4b5edf 100644 --- a/wd_dh.c +++ b/wd_dh.c @@ -432,8 +432,10 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req) ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_dh_setting.pool, idx, (void **)&msg); - if (mid < 0) - return -WD_EBUSY; + if (unlikely(mid < 0)) { + WD_ERR("failed to get msg from pool!\n"); + return mid; + }
ret = fill_dh_msg(msg, req, (struct wd_dh_sess *)sess); if (ret) diff --git a/wd_digest.c b/wd_digest.c index be3c20e6..9fb9c9ba 100644 --- a/wd_digest.c +++ b/wd_digest.c @@ -698,8 +698,8 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req) msg_id = wd_get_msg_from_pool(&wd_digest_setting.pool, idx, (void **)&msg); if (unlikely(msg_id < 0)) { - WD_ERR("busy, failed to get msg from pool!\n"); - return -WD_EBUSY; + WD_ERR("failed to get msg from pool!\n"); + return msg_id; }
fill_request_msg(msg, req, dsess); diff --git a/wd_ecc.c b/wd_ecc.c index 3a7fceed..a937ff92 100644 --- a/wd_ecc.c +++ b/wd_ecc.c @@ -2271,8 +2271,10 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req) ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_ecc_setting.pool, idx, (void **)&msg); - if (mid < 0) - return -WD_EBUSY; + if (unlikely(mid < 0)) { + WD_ERR("failed to get msg from pool!\n"); + return mid; + }
ret = fill_ecc_msg(msg, req, (struct wd_ecc_sess *)sess); if (ret) diff --git a/wd_rsa.c b/wd_rsa.c index f5c96987..c6b032ea 100644 --- a/wd_rsa.c +++ b/wd_rsa.c @@ -491,8 +491,10 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req) ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_rsa_setting.pool, idx, (void **)&msg); - if (mid < 0) - return -WD_EBUSY; + if (unlikely(mid < 0)) { + WD_ERR("failed to get msg from pool!\n"); + return mid; + }
ret = fill_rsa_msg(msg, req, (struct wd_rsa_sess *)sess); if (ret) diff --git a/wd_util.c b/wd_util.c index bb5f3efc..abc282be 100644 --- a/wd_util.c +++ b/wd_util.c @@ -448,6 +448,10 @@ int wd_get_msg_from_pool(struct wd_async_msg_pool *pool, __u32 cnt = 0; __u32 idx = p->tail;
+ /* Scheduler set a sync ctx */ + if (!msg_num) + return -WD_EINVAL; + while (__atomic_test_and_set(&p->used[idx], __ATOMIC_ACQUIRE)) { idx = (idx + 1) % msg_num; cnt++;
Fix double-free error.
Signed-off-by: Qi Tao taoqi10@huawei.com --- wd.c | 3 --- 1 file changed, 3 deletions(-)
diff --git a/wd.c b/wd.c index 964d3e9f..0c65a61c 100644 --- a/wd.c +++ b/wd.c @@ -940,9 +940,6 @@ void wd_release_alg_cap(struct wd_capability *head) cap_pnext = cap_pnext->next; free(cap_node); } - - if (head) - free(head); }
struct wd_capability *wd_get_alg_cap(void)