* [PATCH v2] drm/bridge: sn65dsi83: Fix an error handling path in sn65dsi83_probe()
@ 2021-12-29 8:58 Christophe JAILLET
2021-12-29 16:10 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2021-12-29 8:58 UTC (permalink / raw)
To: andrzej.hajda, narmstrong, robert.foss, Laurent.pinchart, jonas,
jernej.skrabec, airlied, daniel, marex, frieder.schrempf,
linus.walleij
Cc: dri-devel, linux-kernel, kernel-janitors, Christophe JAILLET
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 SN65DSI84 driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
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 = of_graph_get_remote_port_parent(endpoint);
of_node_put(endpoint);
- 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 = -EINVAL;
+ goto err_put_node;
+ }
+ if (!ctx->host_node) {
+ ret = -ENODEV;
+ goto err_put_node;
+ }
ctx->lvds_dual_link = false;
ctx->lvds_dual_link_even_odd_swap = false;
@@ -590,16 +594,22 @@ static int sn65dsi83_parse_dt(struct sn65dsi83 *ctx, enum sn65dsi83_model model)
ret = drm_of_find_panel_or_bridge(dev->of_node, 2, 0, &panel, &panel_bridge);
if (ret < 0)
- return ret;
+ goto err_put_node;
if (panel) {
panel_bridge = devm_drm_panel_bridge_add(dev, panel);
- if (IS_ERR(panel_bridge))
- return PTR_ERR(panel_bridge);
+ if (IS_ERR(panel_bridge)) {
+ ret = PTR_ERR(panel_bridge);
+ goto err_put_node;
+ }
}
ctx->panel_bridge = panel_bridge;
return 0;
+
+err_put_node:
+ of_node_put(ctx->host_node);
+ return ret;
}
static int sn65dsi83_host_attach(struct sn65dsi83 *ctx)
@@ -673,8 +683,10 @@ static int sn65dsi83_probe(struct i2c_client *client,
return ret;
ctx->regmap = devm_regmap_init_i2c(client, &sn65dsi83_regmap_config);
- if (IS_ERR(ctx->regmap))
- return PTR_ERR(ctx->regmap);
+ if (IS_ERR(ctx->regmap)) {
+ ret = PTR_ERR(ctx->regmap);
+ goto err_put_node;
+ }
dev_set_drvdata(dev, ctx);
i2c_set_clientdata(client, ctx);
@@ -691,6 +703,8 @@ static int sn65dsi83_probe(struct i2c_client *client,
err_remove_bridge:
drm_bridge_remove(&ctx->bridge);
+err_put_node:
+ of_node_put(ctx->host_node);
return ret;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] drm/bridge: sn65dsi83: Fix an error handling path in sn65dsi83_probe()
2021-12-29 8:58 [PATCH v2] drm/bridge: sn65dsi83: Fix an error handling path in sn65dsi83_probe() Christophe JAILLET
@ 2021-12-29 16:10 ` Laurent Pinchart
2022-01-03 10:30 ` Robert Foss
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2021-12-29 16:10 UTC (permalink / raw)
To: Christophe JAILLET
Cc: andrzej.hajda, narmstrong, robert.foss, jonas, jernej.skrabec,
airlied, daniel, marex, frieder.schrempf, linus.walleij,
dri-devel, linux-kernel, kernel-janitors
Hi Christophe,
Thank you for the patch.
On Wed, Dec 29, 2021 at 09:58:44AM +0100, Christophe JAILLET wrote:
> 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 SN65DSI84 driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> 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 = of_graph_get_remote_port_parent(endpoint);
> of_node_put(endpoint);
>
> - 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 = -EINVAL;
> + goto err_put_node;
> + }
> + if (!ctx->host_node) {
> + ret = -ENODEV;
> + goto err_put_node;
> + }
>
> ctx->lvds_dual_link = false;
> ctx->lvds_dual_link_even_odd_swap = false;
> @@ -590,16 +594,22 @@ static int sn65dsi83_parse_dt(struct sn65dsi83 *ctx, enum sn65dsi83_model model)
>
> ret = drm_of_find_panel_or_bridge(dev->of_node, 2, 0, &panel, &panel_bridge);
> if (ret < 0)
> - return ret;
> + goto err_put_node;
> if (panel) {
> panel_bridge = devm_drm_panel_bridge_add(dev, panel);
> - if (IS_ERR(panel_bridge))
> - return PTR_ERR(panel_bridge);
> + if (IS_ERR(panel_bridge)) {
> + ret = PTR_ERR(panel_bridge);
> + goto err_put_node;
> + }
> }
>
> ctx->panel_bridge = panel_bridge;
>
> return 0;
> +
> +err_put_node:
> + of_node_put(ctx->host_node);
> + return ret;
> }
>
> static int sn65dsi83_host_attach(struct sn65dsi83 *ctx)
> @@ -673,8 +683,10 @@ static int sn65dsi83_probe(struct i2c_client *client,
> return ret;
>
> ctx->regmap = devm_regmap_init_i2c(client, &sn65dsi83_regmap_config);
> - if (IS_ERR(ctx->regmap))
> - return PTR_ERR(ctx->regmap);
> + if (IS_ERR(ctx->regmap)) {
> + ret = PTR_ERR(ctx->regmap);
> + goto err_put_node;
> + }
>
> dev_set_drvdata(dev, ctx);
> i2c_set_clientdata(client, ctx);
> @@ -691,6 +703,8 @@ static int sn65dsi83_probe(struct i2c_client *client,
>
> err_remove_bridge:
> drm_bridge_remove(&ctx->bridge);
> +err_put_node:
> + of_node_put(ctx->host_node);
> return ret;
> }
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] drm/bridge: sn65dsi83: Fix an error handling path in sn65dsi83_probe()
2021-12-29 16:10 ` Laurent Pinchart
@ 2022-01-03 10:30 ` Robert Foss
0 siblings, 0 replies; 3+ messages in thread
From: Robert Foss @ 2022-01-03 10:30 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Christophe JAILLET, andrzej.hajda, narmstrong, jonas,
jernej.skrabec, airlied, daniel, marex, frieder.schrempf,
linus.walleij, dri-devel, linux-kernel, kernel-janitors
Applied to drm-misc-next
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-03 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-29 8:58 [PATCH v2] drm/bridge: sn65dsi83: Fix an error handling path in sn65dsi83_probe() Christophe JAILLET
2021-12-29 16:10 ` Laurent Pinchart
2022-01-03 10:30 ` Robert Foss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox