diff options
author | YueHaibing <yuehaibing@huawei.com> | 2019-11-14 10:30:05 +0300 |
---|---|---|
committer | Vasily Gorbik <gor@linux.ibm.com> | 2019-11-20 14:58:12 +0300 |
commit | 0398d4ab1677f7d8cd43aac2aa29a93dfcf9e2e3 (patch) | |
tree | 7c917ec8fbe0c2648e3901387861e1923c1e5a47 /arch | |
parent | 8b57e7c852fc58a62e668a83c0fa8d9246131803 (diff) | |
download | linux-0398d4ab1677f7d8cd43aac2aa29a93dfcf9e2e3.tar.xz |
s390/crypto: Fix unsigned variable compared with zero
s390_crypto_shash_parmsize() return type is int, it
should not be stored in a unsigned variable, which
compared with zero.
Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 3c2eb6b76cab ("s390/crypto: Support for SHA3 via CPACF (MSA6)")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Joerg Schmidbauer <jschmidb@linux.vnet.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/s390/crypto/sha_common.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/s390/crypto/sha_common.c b/arch/s390/crypto/sha_common.c index d39e0f079217..686fe7aa192f 100644 --- a/arch/s390/crypto/sha_common.c +++ b/arch/s390/crypto/sha_common.c @@ -74,14 +74,17 @@ int s390_sha_final(struct shash_desc *desc, u8 *out) struct s390_sha_ctx *ctx = shash_desc_ctx(desc); unsigned int bsize = crypto_shash_blocksize(desc->tfm); u64 bits; - unsigned int n, mbl_offset; + unsigned int n; + int mbl_offset; n = ctx->count % bsize; bits = ctx->count * 8; - mbl_offset = s390_crypto_shash_parmsize(ctx->func) / sizeof(u32); + mbl_offset = s390_crypto_shash_parmsize(ctx->func); if (mbl_offset < 0) return -EINVAL; + mbl_offset = mbl_offset / sizeof(u32); + /* set total msg bit length (mbl) in CPACF parmblock */ switch (ctx->func) { case CPACF_KLMD_SHA_1: |