drm/rockchip: analogix_dp: Add a sanity check for rockchip_drm_psr_register()
authorJeffy Chen <jeffy.chen@rock-chips.com>
Wed, 10 Jan 2018 16:23:43 +0000 (17:23 +0100)
committerHeiko Stuebner <heiko@sntech.de>
Thu, 1 Mar 2018 15:21:08 +0000 (16:21 +0100)
The rockchip_drm_psr_register() can fail, so add a sanity check for that.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
[moved psr_unregister reordering in unbind to separate patch]
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20180110162348.22765-4-thierry.escande@collabora.com
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c

index 37250ab63bd741abe4e76374895267cc963f04e1..ea47573f5b756f187d666e3c892549f15fb678bd 100644 (file)
@@ -354,15 +354,22 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
        dp->psr_state = ~EDP_VSC_PSR_STATE_ACTIVE;
        INIT_WORK(&dp->psr_work, analogix_dp_psr_work);
 
-       rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
+       ret = rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set);
+       if (ret < 0)
+               goto err_cleanup_encoder;
 
        dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
        if (IS_ERR(dp->adp)) {
-               dp->encoder.funcs->destroy(&dp->encoder);
-               return PTR_ERR(dp->adp);
+               ret = PTR_ERR(dp->adp);
+               goto err_unreg_psr;
        }
 
        return 0;
+err_unreg_psr:
+       rockchip_drm_psr_unregister(&dp->encoder);
+err_cleanup_encoder:
+       dp->encoder.funcs->destroy(&dp->encoder);
+       return ret;
 }
 
 static void rockchip_dp_unbind(struct device *dev, struct device *master,