Commit ccb679f
crypto: starfive - Fix memory leak in starfive_aes_aead_do_one_req()
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: 7467147 ("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>1 parent cd576c8 commit ccb679f
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | | - | |
| 672 | + | |
| 673 | + | |
673 | 674 | | |
| 675 | + | |
674 | 676 | | |
675 | 677 | | |
676 | 678 | | |
| |||
681 | 683 | | |
682 | 684 | | |
683 | 685 | | |
684 | | - | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
685 | 689 | | |
| 690 | + | |
686 | 691 | | |
687 | 692 | | |
688 | 693 | | |
| |||
0 commit comments