PM: AVS: qcom-cpr: Fix an error handling path in cpr_probe()

Message ID 0f520597dbad89ab99c217c8986912fa53eaf5f9.1671293108.git.christophe.jaillet@wanadoo.fr
State New
Headers
Series PM: AVS: qcom-cpr: Fix an error handling path in cpr_probe() |

Commit Message

Christophe JAILLET Dec. 17, 2022, 4:05 p.m. UTC
  If an error occurs after a successful pm_genpd_init() call, it should be
undone by a corresponding pm_genpd_remove().

Add the missing call in the error handling path, as already done in the
remove function.

Fixes: bf6910abf548 ("power: avs: Add support for CPR (Core Power Reduction)")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/soc/qcom/cpr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Ulf Hansson Jan. 2, 2023, 3:12 p.m. UTC | #1
On Sat, 17 Dec 2022 at 17:05, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> If an error occurs after a successful pm_genpd_init() call, it should be
> undone by a corresponding pm_genpd_remove().
>
> Add the missing call in the error handling path, as already done in the
> remove function.
>
> Fixes: bf6910abf548 ("power: avs: Add support for CPR (Core Power Reduction)")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/soc/qcom/cpr.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/qcom/cpr.c b/drivers/soc/qcom/cpr.c
> index e9b854ed1bdf..144ea68e0920 100644
> --- a/drivers/soc/qcom/cpr.c
> +++ b/drivers/soc/qcom/cpr.c
> @@ -1708,12 +1708,16 @@ static int cpr_probe(struct platform_device *pdev)
>
>         ret = of_genpd_add_provider_simple(dev->of_node, &drv->pd);
>         if (ret)
> -               return ret;
> +               goto err_remove_genpd;
>
>         platform_set_drvdata(pdev, drv);
>         cpr_debugfs_init(drv);
>
>         return 0;
> +
> +err_remove_genpd:
> +       pm_genpd_remove(&drv->pd);
> +       return ret;
>  }
>
>  static int cpr_remove(struct platform_device *pdev)
> --
> 2.34.1
>
  
Bjorn Andersson Jan. 10, 2023, 4:17 p.m. UTC | #2
On Sat, 17 Dec 2022 17:05:41 +0100, Christophe JAILLET wrote:
> If an error occurs after a successful pm_genpd_init() call, it should be
> undone by a corresponding pm_genpd_remove().
> 
> Add the missing call in the error handling path, as already done in the
> remove function.
> 
> 
> [...]

Applied, thanks!

[1/1] PM: AVS: qcom-cpr: Fix an error handling path in cpr_probe()
      commit: 6049aae52392539e505bfb8ccbcff3c26f1d2f0b

Best regards,
  

Patch

diff --git a/drivers/soc/qcom/cpr.c b/drivers/soc/qcom/cpr.c
index e9b854ed1bdf..144ea68e0920 100644
--- a/drivers/soc/qcom/cpr.c
+++ b/drivers/soc/qcom/cpr.c
@@ -1708,12 +1708,16 @@  static int cpr_probe(struct platform_device *pdev)
 
 	ret = of_genpd_add_provider_simple(dev->of_node, &drv->pd);
 	if (ret)
-		return ret;
+		goto err_remove_genpd;
 
 	platform_set_drvdata(pdev, drv);
 	cpr_debugfs_init(drv);
 
 	return 0;
+
+err_remove_genpd:
+	pm_genpd_remove(&drv->pd);
+	return ret;
 }
 
 static int cpr_remove(struct platform_device *pdev)