drm/sti: hdmi: remove bridge when component_add fails
Subsystems (3)
PATCH 1/1 drm/sti: hdmi: remove bridge when component_add fails
when component_add fails in sti_hdmi_probe remove the drm bridge and put i2c adapter before return
--- drivers/gpu/drm/sti/sti_hdmi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/sti/sti_hdmi.c +6 -1
@@ -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);
Signature · 1 line
2.43.0
Hello,
Quoted 16 lines · Osama Abdelkader
when
component_addfails insti_hdmi_proberemove the drm bridge and put i2c adapter before returnSigned-off-by Osama Abdelkader <[email protected]>--- drivers/gpu/drm/sti/sti_hdmi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/gpu/drm/sti/sti_hdmi.c +0
-0@@ -1460,8 +1460,13 @@ static int sti_hdmi_probe(struct platform_device *pdev)platform_set_drvdata (pdev, hdmi);drm_bridge_add (&hdmi->bridge);
drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device *pdev) · line 1471
Quoted 10 lines
drivers/gpu/drm/sti/sti_hdmi.c +6
-1-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