cypto: mediatek - fix leaks in mtk_desc_ring_alloc
authorXiaoliang Pang <dawning.pang@gmail.com>
Mon, 14 Sep 2020 03:00:51 +0000 (11:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 08:07:02 +0000 (09:07 +0100)
commitc5da13f02748d20aa5d00cac3172183def38e956
treeee1b05d738c1a92aa44f0b6e78a3c2a19cd0e6a2
parent65119594438d73e049a9df2f3041ce8174f97944
cypto: mediatek - fix leaks in mtk_desc_ring_alloc

[ Upstream commit 228d284aac61283cde508a925d666f854b57af63 ]

In the init loop, if an error occurs in function 'dma_alloc_coherent',
then goto the err_cleanup section, after run i--,
in the array ring, the struct mtk_ring with index i will not be released,
causing memory leaks

Fixes: 785e5c616c849 ("crypto: mediatek - Add crypto driver support for some MediaTek chips")
Cc: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Xiaoliang Pang <dawning.pang@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/mediatek/mtk-platform.c