linux/drivers/crypto/starfive
Zilin Guan 38d80307de crypto: starfive - Fix memory leak in starfive_aes_aead_do_one_req()
[ Upstream commit ccb679fdae ]

The starfive_aes_aead_do_one_req() function allocates rctx->adata with
kzalloc() but fails to free it if sg_copy_to_buffer() or
starfive_aes_hw_init() fails, which lead to memory leaks.

Since rctx->adata is unconditionally freed after the write_adata
operations, ensure consistent cleanup by freeing the allocation in these
earlier error paths as well.

Compile tested only. Issue found using a prototype static analysis tool
and code review.

Fixes: 7467147ef9 ("crypto: starfive - Use dma for aes requests")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-03-04 07:19:40 -05:00
..
jh7110-aes.c crypto: starfive - Fix memory leak in starfive_aes_aead_do_one_req() 2026-03-04 07:19:40 -05:00
jh7110-cryp.c crypto: starfive - Use dma for aes requests 2024-04-02 10:49:38 +08:00
jh7110-cryp.h crypto: starfive - Fix nent assignment in rsa dec 2024-07-06 10:20:00 +10:00
jh7110-hash.c crypto: starfive - Correctly handle return of sg_nents_for_len 2025-12-18 13:55:05 +01:00
jh7110-rsa.c crypto: starfive - Fix nent assignment in rsa dec 2024-07-06 10:20:00 +10:00
Kconfig crypto: starfive - Use dma for aes requests 2024-04-02 10:49:38 +08:00
Makefile crypto: starfive - Add AES skcipher and aead support 2023-07-28 18:20:25 +08:00