]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: starfive - Correctly handle return of sg_nents_for_len
authorHaotian Zhang <vulab@iscas.ac.cn>
Mon, 10 Nov 2025 06:54:38 +0000 (14:54 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:11 +0000 (14:03 +0100)
commit9b3f71cf02e04cfaa482155e3078707fe7f8aef4
tree35d1d4a7fac6483fe8ebf377ff37f9d06b58021a
parenta6c22c91b6284e4713c0cf5b20ab3c9c71b77ae8
crypto: starfive - Correctly handle return of sg_nents_for_len

[ Upstream commit e9eb52037a529fbb307c290e9951a62dd728b03d ]

The return value of sg_nents_for_len was assigned to an unsigned long
in starfive_hash_digest, causing negative error codes to be converted
to large positive integers.

Add error checking for sg_nents_for_len and return immediately on
failure to prevent potential buffer overflows.

Fixes: 7883d1b28a2b ("crypto: starfive - Add hash and HMAC support")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/starfive/jh7110-hash.c