Skip to content

Commit dad823f

Browse files
tititiou36gregkh
authored andcommitted
dmaengine: fsl-qdma: Fix a memory leak related to the status queue DMA
[ Upstream commit 968bc1d ] This dma_alloc_coherent() is undone in the remove function, but not in the error handling path of fsl_qdma_probe(). Switch to the managed version to fix the issue in the probe and simplify the remove function. Fixes: b092529 ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/a0ef5d0f5a47381617ef339df776ddc68ce48173.1704621515.git.christophe.jaillet@wanadoo.fr Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b6d19f4 commit dad823f

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

drivers/dma/fsl-qdma.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ static struct fsl_qdma_queue
563563
/*
564564
* Buffer for queue command
565565
*/
566-
status_head->cq = dma_alloc_coherent(&pdev->dev,
567-
sizeof(struct fsl_qdma_format) *
568-
status_size,
569-
&status_head->bus_addr,
570-
GFP_KERNEL);
566+
status_head->cq = dmam_alloc_coherent(&pdev->dev,
567+
sizeof(struct fsl_qdma_format) *
568+
status_size,
569+
&status_head->bus_addr,
570+
GFP_KERNEL);
571571
if (!status_head->cq) {
572572
devm_kfree(&pdev->dev, status_head);
573573
return NULL;
@@ -1268,8 +1268,6 @@ static void fsl_qdma_cleanup_vchan(struct dma_device *dmadev)
12681268

12691269
static int fsl_qdma_remove(struct platform_device *pdev)
12701270
{
1271-
int i;
1272-
struct fsl_qdma_queue *status;
12731271
struct device_node *np = pdev->dev.of_node;
12741272
struct fsl_qdma_engine *fsl_qdma = platform_get_drvdata(pdev);
12751273

@@ -1278,11 +1276,6 @@ static int fsl_qdma_remove(struct platform_device *pdev)
12781276
of_dma_controller_free(np);
12791277
dma_async_device_unregister(&fsl_qdma->dma_dev);
12801278

1281-
for (i = 0; i < fsl_qdma->block_number; i++) {
1282-
status = fsl_qdma->status[i];
1283-
dma_free_coherent(&pdev->dev, sizeof(struct fsl_qdma_format) *
1284-
status->n_cq, status->cq, status->bus_addr);
1285-
}
12861279
return 0;
12871280
}
12881281

0 commit comments

Comments
 (0)