From: Wenkai Lin <linwenkai6@hisilicon.com> In sm3_ce_drv_send and isa_ce_cipher_send, the return value of the software digest/cipher computation (do_sm3_ce, do_hmac_sm3_ce, sm4_xts_encrypt, sm4_xts_decrypt) is silently overwritten by the subsequent wd_get_sqe_from_queue call. If the computation fails, the error is swallowed and the function may return success. Add an early return on error before calling wd_get_sqe_from_queue so that a failed computation does not proceed to queue operations. Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com> --- drv/isa_ce_sm3.c | 2 ++ drv/isa_ce_sm4.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drv/isa_ce_sm3.c b/drv/isa_ce_sm3.c index b41f6c5..117b95e 100644 --- a/drv/isa_ce_sm3.c +++ b/drv/isa_ce_sm3.c @@ -374,6 +374,8 @@ static int sm3_ce_drv_send(handle_t ctx, void *digest_msg) WD_ERR("invalid digest mode!\n"); ret = -WD_EINVAL; } + if (ret) + return ret; ret = wd_get_sqe_from_queue(sfctx, msg->tag); if (ret) diff --git a/drv/isa_ce_sm4.c b/drv/isa_ce_sm4.c index 863b99e..7547c00 100644 --- a/drv/isa_ce_sm4.c +++ b/drv/isa_ce_sm4.c @@ -399,6 +399,8 @@ static int isa_ce_cipher_send(handle_t ctx, void *wd_msg) ret = sm4_xts_encrypt(msg, &rkey); else ret = sm4_xts_decrypt(msg, &rkey); + if (ret) + return ret; break; default: WD_ERR("The current block cipher mode is not supported!\n"); -- 2.50.1.windows.1