Skip to content

Commit 1417f59

Browse files
jason77-wangvinodkoul
authored andcommitted
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 <[email protected]> Reviewed-by: Sascha Hauer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent f3dc1b3 commit 1417f59

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/dma/imx-sdma.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,10 +1521,12 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac,
15211521
sdma_config_ownership(sdmac, false, true, false);
15221522

15231523
if (sdma_load_context(sdmac))
1524-
goto err_desc_out;
1524+
goto err_bd_out;
15251525

15261526
return desc;
15271527

1528+
err_bd_out:
1529+
sdma_free_bd(desc);
15281530
err_desc_out:
15291531
kfree(desc);
15301532
err_out:

0 commit comments

Comments
 (0)