From patchwork Tue Jun 20 06:50:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13285220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11B06EB64D8 for ; Tue, 20 Jun 2023 06:50:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB69E10E00F; Tue, 20 Jun 2023 06:50:52 +0000 (UTC) Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6421C10E00F for ; Tue, 20 Jun 2023 06:50:51 +0000 (UTC) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:b30c:87ec:6d02:5999]) by michel.telenet-ops.be with bizsmtp id BJql2A00K4R9QC306JqlNP; Tue, 20 Jun 2023 08:50:47 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1qBVBv-00992H-Cs; Tue, 20 Jun 2023 08:50:45 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1qBVCP-0018vI-7X; Tue, 20 Jun 2023 08:50:45 +0200 From: Geert Uytterhoeven To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Laurent Pinchart , David Airlie , Daniel Vetter Subject: [PATCH v2] drm/bridge_connector: Handle drm_connector_init_with_ddc() failures Date: Tue, 20 Jun 2023 08:50:44 +0200 Message-Id: <53b00f9812deddf90297e42aa45a4a9988c70076.1687243706.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_connector_init_with_ddc() can fail, but the call in drm_bridge_connector_init() does not check that. Fix this by adding the missing error handling. Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart Reviewed-by: Maxime Ripard --- v2: - Move declaration of ret to its own line, - Add Reviewed-by. --- drivers/gpu/drm/drm_bridge_connector.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index 19ae4a177ac386b2..1f6fc9b0ae649f54 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -318,6 +318,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, struct i2c_adapter *ddc = NULL; struct drm_bridge *bridge, *panel_bridge = NULL; int connector_type; + int ret; bridge_connector = kzalloc(sizeof(*bridge_connector), GFP_KERNEL); if (!bridge_connector) @@ -368,8 +369,14 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, return ERR_PTR(-EINVAL); } - drm_connector_init_with_ddc(drm, connector, &drm_bridge_connector_funcs, - connector_type, ddc); + ret = drm_connector_init_with_ddc(drm, connector, + &drm_bridge_connector_funcs, + connector_type, ddc); + if (ret) { + kfree(bridge_connector); + return ERR_PTR(ret); + } + drm_connector_helper_add(connector, &drm_bridge_connector_helper_funcs); if (bridge_connector->bridge_hpd)