All of lore.kernel.org
 help / color / mirror / Atom feed
* [1/1] dmaengine:jz4740:fix memory leak
  2018-04-04  3:21 ` [PATCH 1/1] " Xidong Wang
@ 2018-04-04  6:00 ` Vinod Koul
  -1 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2018-04-04  6:00 UTC (permalink / raw)
  To: Xidong Wang; +Cc: Dan Williams, dmaengine, linux-kernel

On Wed, Apr 04, 2018 at 11:21:58AM +0800, Xidong Wang wrote:
> In function jz4740_dma_probe(), the memory allocated by
> clk_get() is not released on the error path that ret, which holds
> the return value of dma_async_device_register(), is not NULL.
> This will result in a memory leak bug.

I dont think we cna cal it mem leak, it seems your ref counting of clock
resource is imbalance as you dont free up which eventually would lead to mem
leak. Also dabove description needs a bit of cleanup please

> 
> Signed-off-by: Xidong Wang <wangxidong_97@163.com>
> ---
>  drivers/dma/dma-jz4740.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c
> index afd5e10..082c158 100644
> --- a/drivers/dma/dma-jz4740.c
> +++ b/drivers/dma/dma-jz4740.c
> @@ -570,6 +570,7 @@ static int jz4740_dma_probe(struct platform_device *pdev)
>  	dma_async_device_unregister(dd);
>  err_clk:
>  	clk_disable_unprepare(dmadev->clk);
> +	clk_put(dmadev->clk);
>  	return ret;
>  }
>  
> -- 
> 2.7.4
> 
>

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [1/1] dmaengine:jz4740:fix memory leak
  2018-04-04  3:21 ` [PATCH 1/1] " Xidong Wang
@ 2018-04-04 12:45 ` Lars-Peter Clausen
  -1 siblings, 0 replies; 6+ messages in thread
From: Lars-Peter Clausen @ 2018-04-04 12:45 UTC (permalink / raw)
  To: Xidong Wang, Vinod Koul, Dan Williams; +Cc: dmaengine, linux-kernel

On 04/04/2018 05:21 AM, Xidong Wang wrote:
> In function jz4740_dma_probe(), the memory allocated by
> clk_get() is not released on the error path that ret, which holds
> the return value of dma_async_device_register(), is not NULL.
> This will result in a memory leak bug.
> 
> Signed-off-by: Xidong Wang <wangxidong_97@163.com>

Maybe use devm_clk_get() since the same clk_put() call is missing in the
remove callback.

> ---
>  drivers/dma/dma-jz4740.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c
> index afd5e10..082c158 100644
> --- a/drivers/dma/dma-jz4740.c
> +++ b/drivers/dma/dma-jz4740.c
> @@ -570,6 +570,7 @@ static int jz4740_dma_probe(struct platform_device *pdev)
>  	dma_async_device_unregister(dd);
>  err_clk:
>  	clk_disable_unprepare(dmadev->clk);
> +	clk_put(dmadev->clk);
>  	return ret;
>  }
>  
>
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [1/1] dmaengine:jz4740:fix memory leak
@ 2018-04-04  3:21 ` Xidong Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Xidong Wang @ 2018-04-04  3:21 UTC (permalink / raw)
  To: Vinod Koul, Dan Williams; +Cc: Xidong Wang, dmaengine, linux-kernel

In function jz4740_dma_probe(), the memory allocated by
clk_get() is not released on the error path that ret, which holds
the return value of dma_async_device_register(), is not NULL.
This will result in a memory leak bug.

Signed-off-by: Xidong Wang <wangxidong_97@163.com>
---
 drivers/dma/dma-jz4740.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c
index afd5e10..082c158 100644
--- a/drivers/dma/dma-jz4740.c
+++ b/drivers/dma/dma-jz4740.c
@@ -570,6 +570,7 @@ static int jz4740_dma_probe(struct platform_device *pdev)
 	dma_async_device_unregister(dd);
 err_clk:
 	clk_disable_unprepare(dmadev->clk);
+	clk_put(dmadev->clk);
 	return ret;
 }
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-04 12:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-04  6:00 [1/1] dmaengine:jz4740:fix memory leak Vinod Koul
2018-04-04  6:00 ` [PATCH 1/1] " Vinod Koul
  -- strict thread matches above, loose matches on Subject: below --
2018-04-04 12:45 [1/1] " Lars-Peter Clausen
2018-04-04 12:45 ` [PATCH 1/1] " Lars-Peter Clausen
2018-04-04  3:21 [1/1] " Xidong Wang
2018-04-04  3:21 ` [PATCH 1/1] " Xidong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.