All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe()'
@ 2020-04-26 20:23 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2020-04-26 20:23 UTC (permalink / raw)
  To: ulf.hansson, drake, kamlesh.gurudasani, colin.king, linux
  Cc: linux-mmc, linux-kernel, kernel-janitors, Christophe JAILLET

If 'devm_request_threaded_irq()' fails, resources allocated by
'mmc_alloc_host()' must be freed.

Fixes: c5413ad815a6 ("mmc: add new Alcor Micro Cardreader SD/MMC driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mmc/host/alcor.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c
index 1aee485d56d4..026ca9194ce5 100644
--- a/drivers/mmc/host/alcor.c
+++ b/drivers/mmc/host/alcor.c
@@ -1104,7 +1104,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
 
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to get irq for data line\n");
-		return ret;
+		goto free_host;
 	}
 
 	mutex_init(&host->cmd_mutex);
@@ -1116,6 +1116,10 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
 	dev_set_drvdata(&pdev->dev, host);
 	mmc_add_host(mmc);
 	return 0;
+
+free_host:
+	mmc_free_host(mmc);
+	return ret;
 }
 
 static int alcor_pci_sdmmc_drv_remove(struct platform_device *pdev)
-- 
2.25.1


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

* [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe()'
@ 2020-04-26 20:23 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2020-04-26 20:23 UTC (permalink / raw)
  To: ulf.hansson, drake, kamlesh.gurudasani, colin.king, linux
  Cc: linux-mmc, linux-kernel, kernel-janitors, Christophe JAILLET

If 'devm_request_threaded_irq()' fails, resources allocated by
'mmc_alloc_host()' must be freed.

Fixes: c5413ad815a6 ("mmc: add new Alcor Micro Cardreader SD/MMC driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mmc/host/alcor.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c
index 1aee485d56d4..026ca9194ce5 100644
--- a/drivers/mmc/host/alcor.c
+++ b/drivers/mmc/host/alcor.c
@@ -1104,7 +1104,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
 
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to get irq for data line\n");
-		return ret;
+		goto free_host;
 	}
 
 	mutex_init(&host->cmd_mutex);
@@ -1116,6 +1116,10 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
 	dev_set_drvdata(&pdev->dev, host);
 	mmc_add_host(mmc);
 	return 0;
+
+free_host:
+	mmc_free_host(mmc);
+	return ret;
 }
 
 static int alcor_pci_sdmmc_drv_remove(struct platform_device *pdev)
-- 
2.25.1

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

* Re: [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe()'
  2020-04-26 20:23 ` Christophe JAILLET
@ 2020-04-27  5:54 ` Markus Elfring
  -1 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2020-04-27  5:54 UTC (permalink / raw)
  To: Christophe Jaillet, linux-mmc
  Cc: kernel-janitors, linux-kernel, Colin Ian King, Daniel Drake,
	Kamlesh Gurudasani, Oleksij Rempel, Ulf Hansson

> If 'devm_request_threaded_irq()' fails, resources allocated by
> 'mmc_alloc_host()' must be freed.

How do you think about a wording variant like the following?

   Subject:
   [PATCH v2] mmc: alcor: Complete exception handling in alcor_pci_sdmmc_drv_probe()

   Change description (according to a solution alternative):
   The exception handling was incomplete in an if branch
   after a failed call of the function “devm_request_threaded_irq”.
   Thus add a call of the function “mmc_free_host” for the release of
   corresponding system resources.


> +++ b/drivers/mmc/host/alcor.c
> @@ -1104,7 +1104,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
>
>  	if (ret) {
>  		dev_err(&pdev->dev, "Failed to get irq for data line\n");
> -		return ret;
> +		goto free_host;
>  	}
>
>  	mutex_init(&host->cmd_mutex);

You propose to perform a jump to other code only once in this implementation.
I find it more succinct to call the desired function then directly.

 		dev_err(…);
+		mmc_free_host(mmc);
 		return ret;


Regards,
Markus

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

* Re: [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe(
@ 2020-04-27  5:54 ` Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2020-04-27  5:54 UTC (permalink / raw)
  To: Christophe Jaillet, linux-mmc
  Cc: kernel-janitors, linux-kernel, Colin Ian King, Daniel Drake,
	Kamlesh Gurudasani, Oleksij Rempel, Ulf Hansson

> If 'devm_request_threaded_irq()' fails, resources allocated by
> 'mmc_alloc_host()' must be freed.

How do you think about a wording variant like the following?

   Subject:
   [PATCH v2] mmc: alcor: Complete exception handling in alcor_pci_sdmmc_drv_probe()

   Change description (according to a solution alternative):
   The exception handling was incomplete in an if branch
   after a failed call of the function “devm_request_threaded_irq”.
   Thus add a call of the function “mmc_free_host” for the release of
   corresponding system resources.


> +++ b/drivers/mmc/host/alcor.c
> @@ -1104,7 +1104,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
>
>  	if (ret) {
>  		dev_err(&pdev->dev, "Failed to get irq for data line\n");
> -		return ret;
> +		goto free_host;
>  	}
>
>  	mutex_init(&host->cmd_mutex);

You propose to perform a jump to other code only once in this implementation.
I find it more succinct to call the desired function then directly.

 		dev_err(…);
+		mmc_free_host(mmc);
 		return ret;


Regards,
Markus

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

* Re: [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe()'
  2020-04-26 20:23 ` Christophe JAILLET
@ 2020-05-05 11:32   ` Ulf Hansson
  -1 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2020-05-05 11:32 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Daniel Drake, Kamlesh Gurudasani, Colin King, Oleksij Rempel,
	linux-mmc, Linux Kernel Mailing List, kernel-janitors

On Sun, 26 Apr 2020 at 22:23, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> If 'devm_request_threaded_irq()' fails, resources allocated by
> 'mmc_alloc_host()' must be freed.
>
> Fixes: c5413ad815a6 ("mmc: add new Alcor Micro Cardreader SD/MMC driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied for fixes, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/alcor.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c
> index 1aee485d56d4..026ca9194ce5 100644
> --- a/drivers/mmc/host/alcor.c
> +++ b/drivers/mmc/host/alcor.c
> @@ -1104,7 +1104,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
>
>         if (ret) {
>                 dev_err(&pdev->dev, "Failed to get irq for data line\n");
> -               return ret;
> +               goto free_host;
>         }
>
>         mutex_init(&host->cmd_mutex);
> @@ -1116,6 +1116,10 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
>         dev_set_drvdata(&pdev->dev, host);
>         mmc_add_host(mmc);
>         return 0;
> +
> +free_host:
> +       mmc_free_host(mmc);
> +       return ret;
>  }
>
>  static int alcor_pci_sdmmc_drv_remove(struct platform_device *pdev)
> --
> 2.25.1
>

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

* Re: [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe(
@ 2020-05-05 11:32   ` Ulf Hansson
  0 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2020-05-05 11:32 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Daniel Drake, Kamlesh Gurudasani, Colin King, Oleksij Rempel,
	linux-mmc, Linux Kernel Mailing List, kernel-janitors

On Sun, 26 Apr 2020 at 22:23, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> If 'devm_request_threaded_irq()' fails, resources allocated by
> 'mmc_alloc_host()' must be freed.
>
> Fixes: c5413ad815a6 ("mmc: add new Alcor Micro Cardreader SD/MMC driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied for fixes, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/alcor.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c
> index 1aee485d56d4..026ca9194ce5 100644
> --- a/drivers/mmc/host/alcor.c
> +++ b/drivers/mmc/host/alcor.c
> @@ -1104,7 +1104,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
>
>         if (ret) {
>                 dev_err(&pdev->dev, "Failed to get irq for data line\n");
> -               return ret;
> +               goto free_host;
>         }
>
>         mutex_init(&host->cmd_mutex);
> @@ -1116,6 +1116,10 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
>         dev_set_drvdata(&pdev->dev, host);
>         mmc_add_host(mmc);
>         return 0;
> +
> +free_host:
> +       mmc_free_host(mmc);
> +       return ret;
>  }
>
>  static int alcor_pci_sdmmc_drv_remove(struct platform_device *pdev)
> --
> 2.25.1
>

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

end of thread, other threads:[~2020-05-05 11:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26 20:23 [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe()' Christophe JAILLET
2020-04-26 20:23 ` Christophe JAILLET
2020-05-05 11:32 ` Ulf Hansson
2020-05-05 11:32   ` [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe( Ulf Hansson
2020-04-27  5:54 [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe()' Markus Elfring
2020-04-27  5:54 ` [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe( Markus Elfring

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.