diff mbox series

[1/2] PM / devfreq: rk3399_dmc: Add missing devfreq_event_disable_edev

Message ID 20191221181855.31380-1-tiny.windzz@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] PM / devfreq: rk3399_dmc: Add missing devfreq_event_disable_edev | expand

Commit Message

Yangtao Li Dec. 21, 2019, 6:18 p.m. UTC
The probe process may fail, but the devfreq event device remains
enabled. Call devfreq_event_disable_edev on the error return path.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/devfreq/rk3399_dmc.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

Comments

Chanwoo Choi Dec. 22, 2019, 4:49 p.m. UTC | #1
Hi,

2019년 12월 22일 (일) 오전 3:21, Yangtao Li <tiny.windzz@gmail.com>님이 작성:
>
> The probe process may fail, but the devfreq event device remains
> enabled. Call devfreq_event_disable_edev on the error return path.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  drivers/devfreq/rk3399_dmc.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c
> index 2f1027c5b647..4f4e7c041888 100644
> --- a/drivers/devfreq/rk3399_dmc.c
> +++ b/drivers/devfreq/rk3399_dmc.c
> @@ -364,7 +364,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
>                         if (res.a0) {
>                                 dev_err(dev, "Failed to set dram param: %ld\n",
>                                         res.a0);
> -                               return -EINVAL;
> +                               ret = -EINVAL;
> +                               goto err_disable_edev;

After jumping err_disable_edev, it calls the dev_pm_opp_of_remove_table().
it is wrong. It doesn't need to remove the table.

>                         }
>                 }
>         }
> @@ -373,8 +374,10 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
>         if (node) {
>                 data->regmap_pmu = syscon_node_to_regmap(node);
>                 of_node_put(node);
> -               if (IS_ERR(data->regmap_pmu))
> -                       return PTR_ERR(data->regmap_pmu);
> +               if (IS_ERR(data->regmap_pmu)) {
> +                       ret = PTR_ERR(data->regmap_pmu);
> +                       goto err_disable_edev;

ditto.

After jumping err_disable_edev, it calls the dev_pm_opp_of_remove_table().
it is wrong. It doesn't need to remove the table.

> +               }
>         }
>
>         regmap_read(data->regmap_pmu, RK3399_PMUGRF_OS_REG2, &val);
> @@ -392,7 +395,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
>                 data->odt_dis_freq = data->timing.lpddr4_odt_dis_freq;
>                 break;
>         default:
> -               return -EINVAL;
> +               ret = -EINVAL;
> +               goto err_disable_edev;

ditto.

>         };
>
>         arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, 0, 0,
> @@ -426,7 +430,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
>          */
>         if (dev_pm_opp_of_add_table(dev)) {
>                 dev_err(dev, "Invalid operating-points in device tree.\n");
> -               return -EINVAL;
> +               ret = -EINVAL;
> +               goto err_disable_edev;

ditto.

>         }
>
>         of_property_read_u32(np, "upthreshold",
> @@ -464,6 +469,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
>
>         return 0;
>
> +err_disable_edev:
> +       devfreq_event_disable_edev(data->edev);

It is wrong. It have to be called under dev_pm_opp_of_remove_table().
It ignores the sequence of exception handling.

>  err_free_opp:
>         dev_pm_opp_of_remove_table(&pdev->dev);
>         return ret;
> --
> 2.17.1
>
Yangtao Li Dec. 22, 2019, 5:42 p.m. UTC | #2
V2 has been sent.

Thx,
Yangtao
diff mbox series

Patch

diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c
index 2f1027c5b647..4f4e7c041888 100644
--- a/drivers/devfreq/rk3399_dmc.c
+++ b/drivers/devfreq/rk3399_dmc.c
@@ -364,7 +364,8 @@  static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 			if (res.a0) {
 				dev_err(dev, "Failed to set dram param: %ld\n",
 					res.a0);
-				return -EINVAL;
+				ret = -EINVAL;
+				goto err_disable_edev;
 			}
 		}
 	}
@@ -373,8 +374,10 @@  static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 	if (node) {
 		data->regmap_pmu = syscon_node_to_regmap(node);
 		of_node_put(node);
-		if (IS_ERR(data->regmap_pmu))
-			return PTR_ERR(data->regmap_pmu);
+		if (IS_ERR(data->regmap_pmu)) {
+			ret = PTR_ERR(data->regmap_pmu);
+			goto err_disable_edev;
+		}
 	}
 
 	regmap_read(data->regmap_pmu, RK3399_PMUGRF_OS_REG2, &val);
@@ -392,7 +395,8 @@  static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 		data->odt_dis_freq = data->timing.lpddr4_odt_dis_freq;
 		break;
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_disable_edev;
 	};
 
 	arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, 0, 0,
@@ -426,7 +430,8 @@  static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 	 */
 	if (dev_pm_opp_of_add_table(dev)) {
 		dev_err(dev, "Invalid operating-points in device tree.\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_disable_edev;
 	}
 
 	of_property_read_u32(np, "upthreshold",
@@ -464,6 +469,8 @@  static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_disable_edev:
+	devfreq_event_disable_edev(data->edev);
 err_free_opp:
 	dev_pm_opp_of_remove_table(&pdev->dev);
 	return ret;