When user calls wd_<alg>_init2, if the input parameter sched_type is 'SCHED_POLICY_BUTT' or task_type is 'TASK_MAX_TYPE', the parameter is not supported, In this case, an error must be returned.
Signed-off-by: Weili Qian qianweili@huawei.com --- wd_dh.c | 3 ++- wd_ecc.c | 3 ++- wd_rsa.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/wd_dh.c b/wd_dh.c index 5a79c6d..cb90093 100644 --- a/wd_dh.c +++ b/wd_dh.c @@ -206,7 +206,8 @@ int wd_dh_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_param if (!flag) return -WD_EEXIST;
- if (!alg || sched_type > SCHED_POLICY_BUTT || task_type < 0 || task_type > TASK_MAX_TYPE) { + if (!alg || sched_type >= SCHED_POLICY_BUTT || + task_type < 0 || task_type >= TASK_MAX_TYPE) { WD_ERR("invalid: input param is wrong!\n"); goto out_clear_init; } diff --git a/wd_ecc.c b/wd_ecc.c index c539ce3..3e90e95 100644 --- a/wd_ecc.c +++ b/wd_ecc.c @@ -272,7 +272,8 @@ int wd_ecc_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_para if (!flag) return -WD_EEXIST;
- if (!alg || sched_type > SCHED_POLICY_BUTT || task_type < 0 || task_type > TASK_MAX_TYPE) { + if (!alg || sched_type >= SCHED_POLICY_BUTT || + task_type < 0 || task_type >= TASK_MAX_TYPE) { WD_ERR("invalid: input param is wrong!\n"); goto out_clear_init; } diff --git a/wd_rsa.c b/wd_rsa.c index 0b0be1c..b72ae23 100644 --- a/wd_rsa.c +++ b/wd_rsa.c @@ -247,7 +247,8 @@ int wd_rsa_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_para if (!flag) return -WD_EEXIST;
- if (!alg || sched_type > SCHED_POLICY_BUTT || task_type < 0 || task_type > TASK_MAX_TYPE) { + if (!alg || sched_type >= SCHED_POLICY_BUTT || + task_type < 0 || task_type >= TASK_MAX_TYPE) { WD_ERR("invalid: input param is wrong!\n"); goto out_clear_init; }