From nobody Wed Jul 1 05:32:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72A10C433EF for ; Wed, 29 Dec 2021 08:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239438AbhL2I6v (ORCPT ); Wed, 29 Dec 2021 03:58:51 -0500 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:49489 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234951AbhL2I6u (ORCPT ); Wed, 29 Dec 2021 03:58:50 -0500 Received: from pop-os.home ([86.243.171.122]) by smtp.orange.fr with ESMTPA id 2UnFnTsapMxZu2UnFnMfwb; Wed, 29 Dec 2021 09:58:49 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 29 Dec 2021 09:58:49 +0100 X-ME-IP: 86.243.171.122 From: Christophe JAILLET To: andrzej.hajda@intel.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@linux.ie, daniel@ffwll.ch, marex@denx.de, frieder.schrempf@kontron.de, linus.walleij@linaro.org Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2] drm/bridge: sn65dsi83: Fix an error handling path in sn65dsi83_probe() Date: Wed, 29 Dec 2021 09:58:44 +0100 Message-Id: <4bc21aed4b60d3d5ac4b28d8b07a6fdd8da6a536.1640768126.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" sn65dsi83_parse_dt() takes a reference on 'ctx->host_node' that must be released in the error handling path of this function and of the probe. This is only done in the remove function up to now. Fixes: ceb515ba29ba ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DS= I84 driver") Signed-off-by: Christophe JAILLET Reviewed-by: Laurent Pinchart --- v2: add error handling in sn65dsi83_parse_dt() [Laurent Pinchart] --- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 32 +++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge= /ti-sn65dsi83.c index 945f08de45f1..314a84ffcea3 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c @@ -560,10 +560,14 @@ static int sn65dsi83_parse_dt(struct sn65dsi83 *ctx, = enum sn65dsi83_model model) ctx->host_node =3D of_graph_get_remote_port_parent(endpoint); of_node_put(endpoint); =20 - if (ctx->dsi_lanes < 0 || ctx->dsi_lanes > 4) - return -EINVAL; - if (!ctx->host_node) - return -ENODEV; + if (ctx->dsi_lanes < 0 || ctx->dsi_lanes > 4) { + ret =3D -EINVAL; + goto err_put_node; + } + if (!ctx->host_node) { + ret =3D -ENODEV; + goto err_put_node; + } =20 ctx->lvds_dual_link =3D false; ctx->lvds_dual_link_even_odd_swap =3D false; @@ -590,16 +594,22 @@ static int sn65dsi83_parse_dt(struct sn65dsi83 *ctx, = enum sn65dsi83_model model) =20 ret =3D drm_of_find_panel_or_bridge(dev->of_node, 2, 0, &panel, &panel_br= idge); if (ret < 0) - return ret; + goto err_put_node; if (panel) { panel_bridge =3D devm_drm_panel_bridge_add(dev, panel); - if (IS_ERR(panel_bridge)) - return PTR_ERR(panel_bridge); + if (IS_ERR(panel_bridge)) { + ret =3D PTR_ERR(panel_bridge); + goto err_put_node; + } } =20 ctx->panel_bridge =3D panel_bridge; =20 return 0; + +err_put_node: + of_node_put(ctx->host_node); + return ret; } =20 static int sn65dsi83_host_attach(struct sn65dsi83 *ctx) @@ -673,8 +683,10 @@ static int sn65dsi83_probe(struct i2c_client *client, return ret; =20 ctx->regmap =3D devm_regmap_init_i2c(client, &sn65dsi83_regmap_config); - if (IS_ERR(ctx->regmap)) - return PTR_ERR(ctx->regmap); + if (IS_ERR(ctx->regmap)) { + ret =3D PTR_ERR(ctx->regmap); + goto err_put_node; + } =20 dev_set_drvdata(dev, ctx); i2c_set_clientdata(client, ctx); @@ -691,6 +703,8 @@ static int sn65dsi83_probe(struct i2c_client *client, =20 err_remove_bridge: drm_bridge_remove(&ctx->bridge); +err_put_node: + of_node_put(ctx->host_node); return ret; } =20 --=20 2.32.0