linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: owl-mmc: Fix a resource leak in an error handling path and in the remove function
@ 2020-12-09 19:42 Christophe JAILLET
  2021-01-11 18:05 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2020-12-09 19:42 UTC (permalink / raw)
  To: ulf.hansson, afaerber, manivannan.sadhasivam
  Cc: linux-mmc, linux-arm-kernel, linux-kernel, kernel-janitors,
	Christophe JAILLET

'dma_request_chan()' calls should be balanced by a corresponding
'dma_release_channel()' call.

Add the missing call both in the error handling path of the probe function
and in the remove function.

Fixes: ff65ffe46d28 ("mmc: Add Actions Semi Owl SoCs SD/MMC driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mmc/host/owl-mmc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/owl-mmc.c b/drivers/mmc/host/owl-mmc.c
index 53b81582f1af..5490962dc8e5 100644
--- a/drivers/mmc/host/owl-mmc.c
+++ b/drivers/mmc/host/owl-mmc.c
@@ -640,7 +640,7 @@ static int owl_mmc_probe(struct platform_device *pdev)
 	owl_host->irq = platform_get_irq(pdev, 0);
 	if (owl_host->irq < 0) {
 		ret = -EINVAL;
-		goto err_free_host;
+		goto err_release_channel;
 	}
 
 	ret = devm_request_irq(&pdev->dev, owl_host->irq, owl_irq_handler,
@@ -648,19 +648,21 @@ static int owl_mmc_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to request irq %d\n",
 			owl_host->irq);
-		goto err_free_host;
+		goto err_release_channel;
 	}
 
 	ret = mmc_add_host(mmc);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to add host\n");
-		goto err_free_host;
+		goto err_release_channel;
 	}
 
 	dev_dbg(&pdev->dev, "Owl MMC Controller Initialized\n");
 
 	return 0;
 
+err_release_channel:
+	dma_release_channel(owl_host->dma);
 err_free_host:
 	mmc_free_host(mmc);
 
@@ -674,6 +676,7 @@ static int owl_mmc_remove(struct platform_device *pdev)
 
 	mmc_remove_host(mmc);
 	disable_irq(owl_host->irq);
+	dma_release_channel(owl_host->dma);
 	mmc_free_host(mmc);
 
 	return 0;
-- 
2.27.0


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

* Re: [PATCH] mmc: owl-mmc: Fix a resource leak in an error handling path and in the remove function
  2020-12-09 19:42 [PATCH] mmc: owl-mmc: Fix a resource leak in an error handling path and in the remove function Christophe JAILLET
@ 2021-01-11 18:05 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2021-01-11 18:05 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Andreas Färber, Manivannan Sadhasivam, linux-mmc, Linux ARM,
	Linux Kernel Mailing List, kernel-janitors

On Wed, 9 Dec 2020 at 20:42, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> 'dma_request_chan()' calls should be balanced by a corresponding
> 'dma_release_channel()' call.
>
> Add the missing call both in the error handling path of the probe function
> and in the remove function.
>
> Fixes: ff65ffe46d28 ("mmc: Add Actions Semi Owl SoCs SD/MMC driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/owl-mmc.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/owl-mmc.c b/drivers/mmc/host/owl-mmc.c
> index 53b81582f1af..5490962dc8e5 100644
> --- a/drivers/mmc/host/owl-mmc.c
> +++ b/drivers/mmc/host/owl-mmc.c
> @@ -640,7 +640,7 @@ static int owl_mmc_probe(struct platform_device *pdev)
>         owl_host->irq = platform_get_irq(pdev, 0);
>         if (owl_host->irq < 0) {
>                 ret = -EINVAL;
> -               goto err_free_host;
> +               goto err_release_channel;
>         }
>
>         ret = devm_request_irq(&pdev->dev, owl_host->irq, owl_irq_handler,
> @@ -648,19 +648,21 @@ static int owl_mmc_probe(struct platform_device *pdev)
>         if (ret) {
>                 dev_err(&pdev->dev, "Failed to request irq %d\n",
>                         owl_host->irq);
> -               goto err_free_host;
> +               goto err_release_channel;
>         }
>
>         ret = mmc_add_host(mmc);
>         if (ret) {
>                 dev_err(&pdev->dev, "Failed to add host\n");
> -               goto err_free_host;
> +               goto err_release_channel;
>         }
>
>         dev_dbg(&pdev->dev, "Owl MMC Controller Initialized\n");
>
>         return 0;
>
> +err_release_channel:
> +       dma_release_channel(owl_host->dma);
>  err_free_host:
>         mmc_free_host(mmc);
>
> @@ -674,6 +676,7 @@ static int owl_mmc_remove(struct platform_device *pdev)
>
>         mmc_remove_host(mmc);
>         disable_irq(owl_host->irq);
> +       dma_release_channel(owl_host->dma);
>         mmc_free_host(mmc);
>
>         return 0;
> --
> 2.27.0
>

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

end of thread, other threads:[~2021-01-11 18:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 19:42 [PATCH] mmc: owl-mmc: Fix a resource leak in an error handling path and in the remove function Christophe JAILLET
2021-01-11 18:05 ` Ulf Hansson

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).