From: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
To: "Osama Abdelkader" <osama.abdelkader@gmail.com>,
"Alain Volmat" <alain.volmat@foss.st.com>,
"Raphael Gallais-Pou" <rgallaispou@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/sti: hdmi: remove bridge when component_add fails
Date: Tue, 14 Apr 2026 09:24:48 +0200 [thread overview]
Message-ID: <DHSP5LBPI5DE.3I9EJO2V8UPH4@bootlin.com> (raw)
In-Reply-To: <20260410194141.275998-1-osama.abdelkader@gmail.com>
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@gmail.com>
> ---
> 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
prev parent reply other threads:[~2026-04-14 7:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 19:41 [PATCH] drm/sti: hdmi: remove bridge when component_add fails Osama Abdelkader
2026-04-14 7:24 ` Luca Ceresoli [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DHSP5LBPI5DE.3I9EJO2V8UPH4@bootlin.com \
--to=luca.ceresoli@bootlin.com \
--cc=airlied@gmail.com \
--cc=alain.volmat@foss.st.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=osama.abdelkader@gmail.com \
--cc=rgallaispou@gmail.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox