]> 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 12:55:05 +0000 (13:55 +0100)
commit0c3854d65cc4402cb8c52d4d773450a06efecab6
tree73650652539e6b1d2bd77bccbd80e347a486f0aa
parentef5e709c0494f294841864fe02f7a447d1721b4f
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