diff options
author | Hui Wang <hui.wang@canonical.com> | 2022-11-30 10:08:00 +0100 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2023-01-18 13:14:29 +0100 |
commit | 1417f59ac0b02130ee56c0c50794b9b257be3d17 (patch) | |
tree | 3c6bf7751d3970818c9fef4768e9a48cab31f46d /drivers | |
parent | dmaengine: Fix double increment of client_count in dma_chan_get() (diff) | |
download | linux-1417f59ac0b02130ee56c0c50794b9b257be3d17.tar.xz linux-1417f59ac0b02130ee56c0c50794b9b257be3d17.zip |
dmaengine: imx-sdma: Fix a possible memory leak in sdma_transfer_init
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dma/imx-sdma.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index fbea5f62dd98..b926abe4fa43 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1521,10 +1521,12 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, sdma_config_ownership(sdmac, false, true, false); if (sdma_load_context(sdmac)) - goto err_desc_out; + goto err_bd_out; return desc; +err_bd_out: + sdma_free_bd(desc); err_desc_out: kfree(desc); err_out: |