mmc: sdhci-of-at91: fix memleak on clk_get failure
diff mbox series

Message ID b2a44d5be2e06ff075f32477e466598bb0f07b36.1577961679.git.mirq-linux@rere.qmqm.pl
State Accepted
Commit a04184ce777b46e92c2b3c93c6dcb2754cb005e1
Headers show
Series
  • mmc: sdhci-of-at91: fix memleak on clk_get failure
Related show

Commit Message

Michał Mirosław Jan. 2, 2020, 10:42 a.m. UTC
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(-)

Comments

Ludovic Desroches Jan. 9, 2020, 7:19 a.m. UTC | #1
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
>
Adrian Hunter Jan. 14, 2020, 12:10 p.m. UTC | #2
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);
>
Ulf Hansson Jan. 16, 2020, 2:39 p.m. UTC | #3
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
>

Patch
diff mbox series

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