Skip to content

Commit 968bc1d

Browse files
tititiou36vinodkoul
authored andcommitted
dmaengine: fsl-qdma: Fix a memory leak related to the status queue DMA
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>
1 parent bc9847c commit 968bc1d

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

drivers/dma/fsl-qdma.c

Lines changed: 5 additions & 13 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,21 +1268,13 @@ static void fsl_qdma_cleanup_vchan(struct dma_device *dmadev)
12681268

12691269
static void 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

12761274
fsl_qdma_irq_exit(pdev, fsl_qdma);
12771275
fsl_qdma_cleanup_vchan(&fsl_qdma->dma_dev);
12781276
of_dma_controller_free(np);
12791277
dma_async_device_unregister(&fsl_qdma->dma_dev);
1280-
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-
}
12861278
}
12871279

12881280
static const struct of_device_id fsl_qdma_dt_ids[] = {

0 commit comments

Comments
 (0)