Commit 968bc1d7 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Vinod Koul

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: b092529e ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/a0ef5d0f5a47381617ef339df776ddc68ce48173.1704621515.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent bc9847c9
...@@ -563,11 +563,11 @@ static struct fsl_qdma_queue ...@@ -563,11 +563,11 @@ static struct fsl_qdma_queue
/* /*
* Buffer for queue command * Buffer for queue command
*/ */
status_head->cq = dma_alloc_coherent(&pdev->dev, status_head->cq = dmam_alloc_coherent(&pdev->dev,
sizeof(struct fsl_qdma_format) * sizeof(struct fsl_qdma_format) *
status_size, status_size,
&status_head->bus_addr, &status_head->bus_addr,
GFP_KERNEL); GFP_KERNEL);
if (!status_head->cq) { if (!status_head->cq) {
devm_kfree(&pdev->dev, status_head); devm_kfree(&pdev->dev, status_head);
return NULL; return NULL;
...@@ -1268,8 +1268,6 @@ static void fsl_qdma_cleanup_vchan(struct dma_device *dmadev) ...@@ -1268,8 +1268,6 @@ static void fsl_qdma_cleanup_vchan(struct dma_device *dmadev)
static void fsl_qdma_remove(struct platform_device *pdev) static void fsl_qdma_remove(struct platform_device *pdev)
{ {
int i;
struct fsl_qdma_queue *status;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct fsl_qdma_engine *fsl_qdma = platform_get_drvdata(pdev); struct fsl_qdma_engine *fsl_qdma = platform_get_drvdata(pdev);
...@@ -1277,12 +1275,6 @@ static void fsl_qdma_remove(struct platform_device *pdev) ...@@ -1277,12 +1275,6 @@ static void fsl_qdma_remove(struct platform_device *pdev)
fsl_qdma_cleanup_vchan(&fsl_qdma->dma_dev); fsl_qdma_cleanup_vchan(&fsl_qdma->dma_dev);
of_dma_controller_free(np); of_dma_controller_free(np);
dma_async_device_unregister(&fsl_qdma->dma_dev); dma_async_device_unregister(&fsl_qdma->dma_dev);
for (i = 0; i < fsl_qdma->block_number; i++) {
status = fsl_qdma->status[i];
dma_free_coherent(&pdev->dev, sizeof(struct fsl_qdma_format) *
status->n_cq, status->cq, status->bus_addr);
}
} }
static const struct of_device_id fsl_qdma_dt_ids[] = { static const struct of_device_id fsl_qdma_dt_ids[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment