linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma/mediatek-hs/probe: Fixed a memory leak when devm_request_irq fails
@ 2019-10-24  4:43 Satendra Singh Thakur
  2019-11-05 16:59 ` Vinod Koul
  0 siblings, 1 reply; 4+ messages in thread
From: Satendra Singh Thakur @ 2019-10-24  4:43 UTC (permalink / raw)
  Cc: Satendra Singh Thakur, Sean Wang, Vinod Koul, Dan Williams,
	Matthias Brugger, dmaengine, linux-arm-kernel, linux-mediatek,
	linux-kernel

When devm_request_irq fails, currently, the function
dma_async_device_unregister gets called. This doesn't free
the resources allocated by of_dma_controller_register.
Therefore, we have called of_dma_controller_free for this purpose.

Signed-off-by: Satendra Singh Thakur <sst2005@gmail.com>
---
 drivers/dma/mediatek/mtk-hsdma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c
index 1a2028e1c29e..4c58da742143 100644
--- a/drivers/dma/mediatek/mtk-hsdma.c
+++ b/drivers/dma/mediatek/mtk-hsdma.c
@@ -997,7 +997,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev)
 	if (err) {
 		dev_err(&pdev->dev,
 			"request_irq failed with err %d\n", err);
-		goto err_unregister;
+		goto err_free;
 	}
 
 	platform_set_drvdata(pdev, hsdma);
@@ -1006,6 +1006,8 @@ static int mtk_hsdma_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_free:
+	of_dma_controller_free(pdev->dev.of_node);
 err_unregister:
 	dma_async_device_unregister(dd);
 
-- 
2.17.1


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

* Re: [PATCH] dma/mediatek-hs/probe: Fixed a memory leak when devm_request_irq fails
  2019-10-24  4:43 [PATCH] dma/mediatek-hs/probe: Fixed a memory leak when devm_request_irq fails Satendra Singh Thakur
@ 2019-11-05 16:59 ` Vinod Koul
  2019-11-09 11:35   ` [PATCH v1] dmaengine: mediatek: hsdma_probe: fixed " Satendra Singh Thakur
  0 siblings, 1 reply; 4+ messages in thread
From: Vinod Koul @ 2019-11-05 16:59 UTC (permalink / raw)
  To: Satendra Singh Thakur
  Cc: Sean Wang, Dan Williams, Matthias Brugger, dmaengine,
	linux-arm-kernel, linux-mediatek, linux-kernel

On 24-10-19, 10:13, Satendra Singh Thakur wrote:
> When devm_request_irq fails, currently, the function
> dma_async_device_unregister gets called. This doesn't free
> the resources allocated by of_dma_controller_register.
> Therefore, we have called of_dma_controller_free for this purpose.

Please revise this one as well!

> 
> Signed-off-by: Satendra Singh Thakur <sst2005@gmail.com>
> ---
>  drivers/dma/mediatek/mtk-hsdma.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c
> index 1a2028e1c29e..4c58da742143 100644
> --- a/drivers/dma/mediatek/mtk-hsdma.c
> +++ b/drivers/dma/mediatek/mtk-hsdma.c
> @@ -997,7 +997,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev)
>  	if (err) {
>  		dev_err(&pdev->dev,
>  			"request_irq failed with err %d\n", err);
> -		goto err_unregister;
> +		goto err_free;
>  	}
>  
>  	platform_set_drvdata(pdev, hsdma);
> @@ -1006,6 +1006,8 @@ static int mtk_hsdma_probe(struct platform_device *pdev)
>  
>  	return 0;
>  
> +err_free:
> +	of_dma_controller_free(pdev->dev.of_node);
>  err_unregister:
>  	dma_async_device_unregister(dd);
>  
> -- 
> 2.17.1

-- 
~Vinod

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

* [PATCH v1] dmaengine: mediatek: hsdma_probe: fixed a memory leak when devm_request_irq fails
  2019-11-05 16:59 ` Vinod Koul
@ 2019-11-09 11:35   ` Satendra Singh Thakur
  2019-11-14  6:47     ` Vinod Koul
  0 siblings, 1 reply; 4+ messages in thread
From: Satendra Singh Thakur @ 2019-11-09 11:35 UTC (permalink / raw)
  Cc: Satendra Singh Thakur, Sean Wang, Dan Williams, Vinod Koul,
	Matthias Brugger, dmaengine, linux-arm-kernel, linux-mediatek,
	linux-kernel

When devm_request_irq fails, currently, the function
dma_async_device_unregister gets called. This doesn't free
the resources allocated by of_dma_controller_register.
Therefore, we have called of_dma_controller_free for this purpose.

Signed-off-by: Satendra Singh Thakur <sst2005@gmail.com>
---
 v1: modified the subject line with new tags

 drivers/dma/mediatek/mtk-hsdma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c
index 1a2028e1c29e..4c58da742143 100644
--- a/drivers/dma/mediatek/mtk-hsdma.c
+++ b/drivers/dma/mediatek/mtk-hsdma.c
@@ -997,7 +997,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev)
 	if (err) {
 		dev_err(&pdev->dev,
 			"request_irq failed with err %d\n", err);
-		goto err_unregister;
+		goto err_free;
 	}
 
 	platform_set_drvdata(pdev, hsdma);
@@ -1006,6 +1006,8 @@ static int mtk_hsdma_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_free:
+	of_dma_controller_free(pdev->dev.of_node);
 err_unregister:
 	dma_async_device_unregister(dd);
 
-- 
2.17.1


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

* Re: [PATCH v1] dmaengine: mediatek: hsdma_probe: fixed a memory leak when devm_request_irq fails
  2019-11-09 11:35   ` [PATCH v1] dmaengine: mediatek: hsdma_probe: fixed " Satendra Singh Thakur
@ 2019-11-14  6:47     ` Vinod Koul
  0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2019-11-14  6:47 UTC (permalink / raw)
  To: Satendra Singh Thakur
  Cc: Sean Wang, Dan Williams, Matthias Brugger, dmaengine,
	linux-arm-kernel, linux-mediatek, linux-kernel

Hi Satendra,

On 09-11-19, 17:05, Satendra Singh Thakur wrote:
> When devm_request_irq fails, currently, the function
> dma_async_device_unregister gets called. This doesn't free
> the resources allocated by of_dma_controller_register.
> Therefore, we have called of_dma_controller_free for this purpose.

This should have been a v2! Anyway I have applied this and other patch

Thanks
-- 
~Vinod

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

end of thread, other threads:[~2019-11-14  6:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-24  4:43 [PATCH] dma/mediatek-hs/probe: Fixed a memory leak when devm_request_irq fails Satendra Singh Thakur
2019-11-05 16:59 ` Vinod Koul
2019-11-09 11:35   ` [PATCH v1] dmaengine: mediatek: hsdma_probe: fixed " Satendra Singh Thakur
2019-11-14  6:47     ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).