From: Wenkai Lin <linwenkai6@hisilicon.com> driver inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/9217 CVE: NA ---------------------------------------------------------------------- The problem that resources are not released in non-backlog mode is fixed. There are three cases: 1. If the device is abnormal, the send function returns EAGAIN and prints an error log. 2. If the device queue is full, the send function returns ENOSPC and does not print anything. 3. The task is sent normally, and EINPROGRESS is returned. In addition, the step of switching to software computing is deleted so that the caller can correctly handle the actual situation. Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com> Signed-off-by: Ruibin Deng <dengruibin@h-partners.com> --- drivers/crypto/hisilicon/sec2/sec_crypto.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index 6750738e8536..9353948f177a 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -345,6 +345,9 @@ static int sec_alg_send_message_retry(struct sec_req *req) ret = qp_send_message(req); } while (ret == -EBUSY && ctr++ < SEC_RETRY_MAX_CNT); + if (ret == -EBUSY) + return -ENOSPC; + return ret; } @@ -1984,12 +1987,10 @@ static int sec_process(struct sec_ctx *ctx, struct sec_req *req) sec_update_iv(req, ctx->alg_type); ret = ctx->req_op->bd_send(ctx, req); - if (unlikely((ret != -EBUSY && ret != -EINPROGRESS))) { + if (likely(ret == -EINPROGRESS || ret == -EBUSY)) + return ret; + else if (ret != -ENOSPC) dev_err_ratelimited(ctx->dev, "send sec request failed!\n"); - goto err_send_req; - } - - return ret; err_send_req: /* As failing, restore the IV from user */ @@ -2006,12 +2007,6 @@ static int sec_process(struct sec_ctx *ctx, struct sec_req *req) err_uninit_req: sec_request_uninit(req); - if (ctx->alg_type == SEC_AEAD) - ret = sec_aead_soft_crypto(ctx, req->aead_req.aead_req, - req->c_req.encrypt); - else - ret = sec_skcipher_soft_crypto(ctx, req->c_req.sk_req, - req->c_req.encrypt); return ret; } -- 2.43.0