digest_bd2_zero_packet_check() and digest_bd3_zero_packet_check() do not check whether the packet length is 0. Therefor, the function name does not match the function semantics.
Signed-off-by: Qi Tao taoqi10@huawei.com --- drv/hisi_sec.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c index df6f56c..ebd9aaf 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -1578,7 +1578,7 @@ static int digest_long_bd_align_check(struct wd_digest_msg *msg) return 0; }
-static int digest_bd2_zero_packet_check(struct wd_digest_msg *msg) +static int digest_bd2_type_check(struct wd_digest_msg *msg) { enum hash_bd_type type = get_hash_bd_type(msg);
@@ -1597,7 +1597,7 @@ static int digest_bd2_zero_packet_check(struct wd_digest_msg *msg) return 0; }
-static int digest_bd3_zero_packet_check(struct wd_digest_msg *msg) +static int digest_bd3_type_check(struct wd_digest_msg *msg) { enum hash_bd_type type = get_hash_bd_type(msg); /* Long hash first and middle bd */ @@ -1618,28 +1618,23 @@ static int digest_bd3_zero_packet_check(struct wd_digest_msg *msg)
static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type) { - int ret; + int ret = 0;
/* * Hardware needs to check the zero byte packet in the block * and long hash mode. First and middle bd not support 0 size, * final bd not need to check it. */ - if (type == BD_TYPE2 && !msg->in_bytes) { - ret = digest_bd2_zero_packet_check(msg); - if (ret) - return ret; - } + if (unlikely(!msg->in_bytes)) { + if (type == BD_TYPE2) + ret = digest_bd2_type_check(msg); + else if (type == BD_TYPE3) + ret = digest_bd3_type_check(msg);
- if (type == BD_TYPE3 && !msg->in_bytes) { - ret = digest_bd3_zero_packet_check(msg); if (ret) return ret; - } - - if (unlikely(msg->in_bytes > MAX_INPUT_DATA_LEN)) { - WD_ERR("digest input length is too long, size = %u\n", - msg->in_bytes); + } else if (unlikely(msg->in_bytes > MAX_INPUT_DATA_LEN)) { + WD_ERR("digest input length is too long, size = %u\n", msg->in_bytes); return -WD_EINVAL; }