Skip to contentSkip to conversation

drm/sti: hdmi: Fix bridge leak on component_add() failure

PATCH New Myeonghun Pak 1 participant 1 message Apr 24

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/sti: hdmi: Fix bridge leak on component_add() failure

sti_hdmi_probe() registers its bridge before adding the component. If component_add() fails, probe returns the error and leaves the bridge registered.

The remove callback unregisters the bridge, but remove is only called after a successful probe. Remove the bridge locally when component_add() fails, then continue through the existing adapter unwind path.

---
 drivers/gpu/drm/sti/sti_hdmi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/sti/sti_hdmi.c +8 -2
index f8222e60b1..d7b61b5b35 100644
@@ -1460,9 +1460,15 @@ 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 bridge_remove;
 
- release_adapter:
+	return 0;
+
+bridge_remove:
+	drm_bridge_remove(&hdmi->bridge);
+release_adapter:
 	i2c_put_adapter(hdmi->ddc_adapt);
 
 	return ret;
Signature · 1 line
2.50.1