Add setup parameter check when create ctx, and remove some redundant code.
Signed-off-by: Zhiqi Song songzhiqi1@huawei.com --- v1/drv/hisi_hpre_udrv.c | 9 ++++----- v1/wd_dh.c | 3 ++- v1/wd_ecc.c | 3 ++- v1/wd_rsa.c | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/v1/drv/hisi_hpre_udrv.c b/v1/drv/hisi_hpre_udrv.c index 92ca8fa..00ea665 100644 --- a/v1/drv/hisi_hpre_udrv.c +++ b/v1/drv/hisi_hpre_udrv.c @@ -292,7 +292,6 @@ static int qm_rsa_out_transfer(struct wcrypto_rsa_msg *msg, if (hw_msg->alg == HPRE_ALG_KG_CRT) { msg->out_bytes = CRT_GEN_PARAMS_SZ(kbytes); *in_len = GEN_PARAMS_SZ_UL(kbytes); - *out_len = msg->out_bytes; wcrypto_get_rsa_kg_out_crt_params(key, &qinv, &dq, &dp); ret = qm_tri_bin_transfer(&qinv, &dq, &dp, "rsa kg qinv&dp&dq"); if (unlikely(ret)) @@ -302,9 +301,7 @@ static int qm_rsa_out_transfer(struct wcrypto_rsa_msg *msg, dq.dsize, dp.dsize); } else if (hw_msg->alg == HPRE_ALG_KG_STD) { msg->out_bytes = GEN_PARAMS_SZ(kbytes); - *out_len = msg->out_bytes; *in_len = GEN_PARAMS_SZ_UL(kbytes); - wcrypto_get_rsa_kg_out_params(key, &d, &n); ret = qm_tri_bin_transfer(&d, &n, NULL, "rsa kg d & n"); if (unlikely(ret)) @@ -314,8 +311,10 @@ static int qm_rsa_out_transfer(struct wcrypto_rsa_msg *msg, } else { *in_len = kbytes; msg->out_bytes = kbytes; - *out_len = msg->out_bytes; } + + *out_len = msg->out_bytes; + return WD_SUCCESS; }
@@ -1913,7 +1912,7 @@ static int fill_sm2_enc_sqe(void *msg, struct qm_queue_info *info, __u16 idx) }
/* split message into two inner request msg - * firest msg used to compute k * g + * first msg used to compute k * g * second msg used to compute k * pb */ ret = split_req(info, req_src, req_dst); diff --git a/v1/wd_dh.c b/v1/wd_dh.c index 9ed0e0d..aab26d6 100644 --- a/v1/wd_dh.c +++ b/v1/wd_dh.c @@ -61,7 +61,8 @@ static int create_ctx_param_check(struct wd_queue *q, return -WD_EINVAL; }
- if (!setup->br.alloc || !setup->br.free) { + if (!setup->br.alloc || !setup->br.free || + !setup->br.iova_map || !setup->br.iova_unmap) { WD_ERR("create dh ctx user mm br err!\n"); return -WD_EINVAL; } diff --git a/v1/wd_ecc.c b/v1/wd_ecc.c index 4151901..36c507a 100644 --- a/v1/wd_ecc.c +++ b/v1/wd_ecc.c @@ -1011,7 +1011,8 @@ static int param_check(struct wd_queue *q, struct wcrypto_ecc_ctx_setup *setup) return -WD_EINVAL; }
- if (unlikely(!setup->br.alloc || !setup->br.free)) { + if (unlikely(!setup->br.alloc || !setup->br.free || + !setup->br.iova_map || !setup->br.iova_unmap)) { WD_ERR("user mm br error!\n"); return -WD_EINVAL; } diff --git a/v1/wd_rsa.c b/v1/wd_rsa.c index 97f0c68..efa02ac 100644 --- a/v1/wd_rsa.c +++ b/v1/wd_rsa.c @@ -554,7 +554,8 @@ static int check_q_setup(struct wd_queue *q, struct wcrypto_rsa_ctx_setup *setup return -WD_EINVAL; }
- if (!setup->br.alloc || !setup->br.free) { + if (!setup->br.alloc || !setup->br.free || + !setup->br.iova_map || !setup->br.iova_unmap) { WD_ERR("create rsa ctx user mm br err!\n"); return -WD_EINVAL; }