Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758724AbeAIOtb (ORCPT + 1 other); Tue, 9 Jan 2018 09:49:31 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58370 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758583AbeAIOtX (ORCPT ); Tue, 9 Jan 2018 09:49:23 -0500 From: Thierry Escande To: Rob Herring , Archit Taneja , Daniel Vetter , Neil Armstrong , Laurent Pinchart , Sandy Huang Cc: Jeffy Chen , Sean Paul , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 3/8] drm/rockchip: analogix_dp: Add a sanity check for rockchip_drm_psr_register() Date: Tue, 9 Jan 2018 15:48:48 +0100 Message-Id: <20180109144853.32536-4-thierry.escande@collabora.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180109144853.32536-1-thierry.escande@collabora.com> References: <20180109144853.32536-1-thierry.escande@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset = "utf-8" Content-Transfert-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Jeffy Chen The rockchip_drm_psr_register() can fail, so add a sanity check for that. Also reorder the calls in unbind() to match bind(). Signed-off-by: Jeffy Chen Signed-off-by: Thierry Escande --- drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index 37250ab63bd7..eb88c52336a7 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -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, @@ -370,8 +377,8 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master, { struct rockchip_dp_device *dp = dev_get_drvdata(dev); - rockchip_drm_psr_unregister(&dp->encoder); analogix_dp_unbind(dp->adp); + rockchip_drm_psr_unregister(&dp->encoder); dp->encoder.funcs->destroy(&dp->encoder); } -- 2.14.1