Linux-mmc Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] mmc: sdhci-of-at91: fix memleak on clk_get failure
@ 2020-01-02 10:42 Michał Mirosław
  2020-01-09  7:19 ` Ludovic Desroches
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michał Mirosław @ 2020-01-02 10:42 UTC (permalink / raw)
  To: linux-mmc
  Cc: Adrian Hunter, Ludovic Desroches, Ulf Hansson, Nicolas Ferre,
	Alexandre Belloni, linux-kernel

sdhci_alloc_host() does its work not using managed infrastructure, so
needs explicit free on error path. Add it where needed.

Cc: <stable@vger.kernel.org>
Fixes: bb5f8ea4d514 ("mmc: sdhci-of-at91: introduce driver for the Atmel SDMMC")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/mmc/host/sdhci-of-at91.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index b2a8c45c9c23..ab2bd314a390 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -345,20 +345,23 @@ static int sdhci_at91_probe(struct platform_device *pdev)
 			priv->mainck = NULL;
 		} else {
 			dev_err(&pdev->dev, "failed to get baseclk\n");
-			return PTR_ERR(priv->mainck);
+			ret = PTR_ERR(priv->mainck);
+			goto sdhci_pltfm_free;
 		}
 	}
 
 	priv->hclock = devm_clk_get(&pdev->dev, "hclock");
 	if (IS_ERR(priv->hclock)) {
 		dev_err(&pdev->dev, "failed to get hclock\n");
-		return PTR_ERR(priv->hclock);
+		ret = PTR_ERR(priv->hclock);
+		goto sdhci_pltfm_free;
 	}
 
 	priv->gck = devm_clk_get(&pdev->dev, "multclk");
 	if (IS_ERR(priv->gck)) {
 		dev_err(&pdev->dev, "failed to get multclk\n");
-		return PTR_ERR(priv->gck);
+		ret = PTR_ERR(priv->gck);
+		goto sdhci_pltfm_free;
 	}
 
 	ret = sdhci_at91_set_clks_presets(&pdev->dev);
-- 
2.20.1


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

* Re: [PATCH] mmc: sdhci-of-at91: fix memleak on clk_get failure
  2020-01-02 10:42 [PATCH] mmc: sdhci-of-at91: fix memleak on clk_get failure Michał Mirosław
@ 2020-01-09  7:19 ` Ludovic Desroches
  2020-01-14 12:10 ` Adrian Hunter
  2020-01-16 14:39 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ludovic Desroches @ 2020-01-09  7:19 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: linux-mmc, Adrian Hunter, Ulf Hansson, Nicolas Ferre,
	Alexandre Belloni, linux-kernel

On Thu, Jan 02, 2020 at 11:42:16AM +0100, Michał Mirosław wrote:
> sdhci_alloc_host() does its work not using managed infrastructure, so
> needs explicit free on error path. Add it where needed.
> 
> Cc: <stable@vger.kernel.org>
> Fixes: bb5f8ea4d514 ("mmc: sdhci-of-at91: introduce driver for the Atmel SDMMC")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>

Thanks

> ---
>  drivers/mmc/host/sdhci-of-at91.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index b2a8c45c9c23..ab2bd314a390 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -345,20 +345,23 @@ static int sdhci_at91_probe(struct platform_device *pdev)
>                         priv->mainck = NULL;
>                 } else {
>                         dev_err(&pdev->dev, "failed to get baseclk\n");
> -                       return PTR_ERR(priv->mainck);
> +                       ret = PTR_ERR(priv->mainck);
> +                       goto sdhci_pltfm_free;
>                 }
>         }
> 
>         priv->hclock = devm_clk_get(&pdev->dev, "hclock");
>         if (IS_ERR(priv->hclock)) {
>                 dev_err(&pdev->dev, "failed to get hclock\n");
> -               return PTR_ERR(priv->hclock);
> +               ret = PTR_ERR(priv->hclock);
> +               goto sdhci_pltfm_free;
>         }
> 
>         priv->gck = devm_clk_get(&pdev->dev, "multclk");
>         if (IS_ERR(priv->gck)) {
>                 dev_err(&pdev->dev, "failed to get multclk\n");
> -               return PTR_ERR(priv->gck);
> +               ret = PTR_ERR(priv->gck);
> +               goto sdhci_pltfm_free;
>         }
> 
>         ret = sdhci_at91_set_clks_presets(&pdev->dev);
> --
> 2.20.1
> 

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

* Re: [PATCH] mmc: sdhci-of-at91: fix memleak on clk_get failure
  2020-01-02 10:42 [PATCH] mmc: sdhci-of-at91: fix memleak on clk_get failure Michał Mirosław
  2020-01-09  7:19 ` Ludovic Desroches
@ 2020-01-14 12:10 ` Adrian Hunter
  2020-01-16 14:39 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2020-01-14 12:10 UTC (permalink / raw)
  To: Michał Mirosław, linux-mmc
  Cc: Ludovic Desroches, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	linux-kernel

On 2/01/20 12:42 pm, Michał Mirosław wrote:
> sdhci_alloc_host() does its work not using managed infrastructure, so
> needs explicit free on error path. Add it where needed.
> 
> Cc: <stable@vger.kernel.org>
> Fixes: bb5f8ea4d514 ("mmc: sdhci-of-at91: introduce driver for the Atmel SDMMC")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-of-at91.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index b2a8c45c9c23..ab2bd314a390 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -345,20 +345,23 @@ static int sdhci_at91_probe(struct platform_device *pdev)
>  			priv->mainck = NULL;
>  		} else {
>  			dev_err(&pdev->dev, "failed to get baseclk\n");
> -			return PTR_ERR(priv->mainck);
> +			ret = PTR_ERR(priv->mainck);
> +			goto sdhci_pltfm_free;
>  		}
>  	}
>  
>  	priv->hclock = devm_clk_get(&pdev->dev, "hclock");
>  	if (IS_ERR(priv->hclock)) {
>  		dev_err(&pdev->dev, "failed to get hclock\n");
> -		return PTR_ERR(priv->hclock);
> +		ret = PTR_ERR(priv->hclock);
> +		goto sdhci_pltfm_free;
>  	}
>  
>  	priv->gck = devm_clk_get(&pdev->dev, "multclk");
>  	if (IS_ERR(priv->gck)) {
>  		dev_err(&pdev->dev, "failed to get multclk\n");
> -		return PTR_ERR(priv->gck);
> +		ret = PTR_ERR(priv->gck);
> +		goto sdhci_pltfm_free;
>  	}
>  
>  	ret = sdhci_at91_set_clks_presets(&pdev->dev);
> 


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

* Re: [PATCH] mmc: sdhci-of-at91: fix memleak on clk_get failure
  2020-01-02 10:42 [PATCH] mmc: sdhci-of-at91: fix memleak on clk_get failure Michał Mirosław
  2020-01-09  7:19 ` Ludovic Desroches
  2020-01-14 12:10 ` Adrian Hunter
@ 2020-01-16 14:39 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2020-01-16 14:39 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: linux-mmc, Adrian Hunter, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Linux Kernel Mailing List

On Thu, 2 Jan 2020 at 11:42, Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
>
> sdhci_alloc_host() does its work not using managed infrastructure, so
> needs explicit free on error path. Add it where needed.
>
> Cc: <stable@vger.kernel.org>
> Fixes: bb5f8ea4d514 ("mmc: sdhci-of-at91: introduce driver for the Atmel SDMMC")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Applied for next, thanks!

Kind regards
Uffe



> ---
>  drivers/mmc/host/sdhci-of-at91.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index b2a8c45c9c23..ab2bd314a390 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -345,20 +345,23 @@ static int sdhci_at91_probe(struct platform_device *pdev)
>                         priv->mainck = NULL;
>                 } else {
>                         dev_err(&pdev->dev, "failed to get baseclk\n");
> -                       return PTR_ERR(priv->mainck);
> +                       ret = PTR_ERR(priv->mainck);
> +                       goto sdhci_pltfm_free;
>                 }
>         }
>
>         priv->hclock = devm_clk_get(&pdev->dev, "hclock");
>         if (IS_ERR(priv->hclock)) {
>                 dev_err(&pdev->dev, "failed to get hclock\n");
> -               return PTR_ERR(priv->hclock);
> +               ret = PTR_ERR(priv->hclock);
> +               goto sdhci_pltfm_free;
>         }
>
>         priv->gck = devm_clk_get(&pdev->dev, "multclk");
>         if (IS_ERR(priv->gck)) {
>                 dev_err(&pdev->dev, "failed to get multclk\n");
> -               return PTR_ERR(priv->gck);
> +               ret = PTR_ERR(priv->gck);
> +               goto sdhci_pltfm_free;
>         }
>
>         ret = sdhci_at91_set_clks_presets(&pdev->dev);
> --
> 2.20.1
>

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-02 10:42 [PATCH] mmc: sdhci-of-at91: fix memleak on clk_get failure Michał Mirosław
2020-01-09  7:19 ` Ludovic Desroches
2020-01-14 12:10 ` Adrian Hunter
2020-01-16 14:39 ` Ulf Hansson

Linux-mmc Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mmc/0 linux-mmc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mmc linux-mmc/ https://lore.kernel.org/linux-mmc \
		linux-mmc@vger.kernel.org
	public-inbox-index linux-mmc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mmc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git