Re: [PATCH] drm/sti: hdmi: remove bridge when component_add fails
From: Luca Ceresoli
Date: Tue Apr 14 2026 - 03:30:01 EST
Hello,
On Fri Apr 10, 2026 at 9:41 PM CEST, Osama Abdelkader wrote:
> when component_add fails in sti_hdmi_probe remove the drm bridge
> and put i2c adapter before return
>
> Signed-off-by: Osama Abdelkader <osama.abdelkader@xxxxxxxxx>
> ---
> drivers/gpu/drm/sti/sti_hdmi.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
> index f8222e60b1e0..839c80a7d954 100644
> --- a/drivers/gpu/drm/sti/sti_hdmi.c
> +++ b/drivers/gpu/drm/sti/sti_hdmi.c
> @@ -1460,8 +1460,13 @@ static int sti_hdmi_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, hdmi);
>
> drm_bridge_add(&hdmi->bridge);
> - return component_add(&pdev->dev, &sti_hdmi_ops);
> + ret = component_add(&pdev->dev, &sti_hdmi_ops);
> + if (ret)
> + goto remove_bridge;
> + return 0;
>
> + remove_bridge:
> + drm_bridge_remove(&hdmi->bridge);
> release_adapter:
> i2c_put_adapter(hdmi->ddc_adapt);
This function has an insane amount of sections like:
if (IS_ERR(...)) {
DRM_ERROR(...);
ret = PTR_ERR(...);
goto release_adapter;
}
I guess all these can be dramatically simplified by using a devm
action. of_get_i2c_adapter_by_node() has no devm_ version but you can add a
release action using devm_add_action_or_reset(). This would allow to
simplify all the error management if()s and avoid any gotos.
On top of that you can just switch to devm_drm_bridge_add().
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com