dmaengine: imx-sdma: Fix a possible memory leak in sdma_transfer_init
authorHui Wang <hui.wang@canonical.com>
Wed, 30 Nov 2022 09:08:00 +0000 (17:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Feb 2023 07:06:33 +0000 (08:06 +0100)
commitce4745a6b8016fae74c95dcd457d4ceef7d98af1
tree1d148be855d384d4588a6b82f7575aae7a0b2d29
parent6b1cebcd9e89a306bd2842f960da839209c696cd
dmaengine: imx-sdma: Fix a possible memory leak in sdma_transfer_init

[ Upstream commit 1417f59ac0b02130ee56c0c50794b9b257be3d17 ]

If the function sdma_load_context() fails, the sdma_desc will be
freed, but the allocated desc->bd is forgot to be freed.

We already met the sdma_load_context() failure case and the log as
below:
[ 450.699064] imx-sdma 30bd0000.dma-controller: Timeout waiting for CH0 ready
...

In this case, the desc->bd will not be freed without this change.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20221130090800.102035-1-hui.wang@canonical.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dma/imx-sdma.c