drm/bridge: Fix error handling in analogix_dp_probe
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 20 Apr 2022 01:16:40 +0000 (01:16 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:47 +0000 (10:22 +0200)
[ Upstream commit 9f15930bb2ef9f031d62ffc49629cbae89137733 ]

In the error handling path, the clk_prepare_enable() function
call should be balanced by a corresponding 'clk_disable_unprepare()'
call, as already done in the remove function.

Fixes: 3424e3a4f844 ("drm: bridge: analogix/dp: split exynos dp driver to bridge directory")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Robert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220420011644.25730-1-linmq006@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c

index b7d2e4449cfaa44caaf0b2f274d879bbfde32a22..7fe19c56f7929c0b87ca07ebc5374d333e0490b2 100644 (file)
@@ -1698,8 +1698,10 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
        dp->reg_base = devm_ioremap_resource(&pdev->dev, res);
-       if (IS_ERR(dp->reg_base))
-               return ERR_CAST(dp->reg_base);
+       if (IS_ERR(dp->reg_base)) {
+               ret = PTR_ERR(dp->reg_base);
+               goto err_disable_clk;
+       }
 
        dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd");
 
@@ -1711,7 +1713,8 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
        if (IS_ERR(dp->hpd_gpiod)) {
                dev_err(dev, "error getting HDP GPIO: %ld\n",
                        PTR_ERR(dp->hpd_gpiod));
-               return ERR_CAST(dp->hpd_gpiod);
+               ret = PTR_ERR(dp->hpd_gpiod);
+               goto err_disable_clk;
        }
 
        if (dp->hpd_gpiod) {
@@ -1731,7 +1734,8 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
 
        if (dp->irq == -ENXIO) {
                dev_err(&pdev->dev, "failed to get irq\n");
-               return ERR_PTR(-ENODEV);
+               ret = -ENODEV;
+               goto err_disable_clk;
        }
 
        ret = devm_request_threaded_irq(&pdev->dev, dp->irq,
@@ -1740,11 +1744,15 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
                                        irq_flags, "analogix-dp", dp);
        if (ret) {
                dev_err(&pdev->dev, "failed to request irq\n");
-               return ERR_PTR(ret);
+               goto err_disable_clk;
        }
        disable_irq(dp->irq);
 
        return dp;
+
+err_disable_clk:
+       clk_disable_unprepare(dp->clock);
+       return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(analogix_dp_probe);