Skip to contentSkip to conversation

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

PATCH In review Myeonghun Pak 2 participants 3 messages Apr 24 – Apr 27

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

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

sti_hda_probe() registers its bridge before adding the component. If component_add() fails, probe returns the error directly 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 so the probe error path matches the successful-probe remove path.

---
 drivers/gpu/drm/sti/sti_hda.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/sti/sti_hda.c +6 -1
index b739782788..9223135c93 100644
@@ -741,6 +741,7 @@ static int sti_hda_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct sti_hda *hda;
 	struct resource *res;
+	int ret;
 
 	DRM_INFO("%s\n", __func__);
 
@@ -783,7 +784,11 @@ static int sti_hda_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, hda);
 
-	return component_add(&pdev->dev, &sti_hda_ops);
+	ret = component_add(&pdev->dev, &sti_hda_ops);
+	if (ret)
+		drm_bridge_remove(&hda->bridge);
+
+	return ret;
 }
 
 static void sti_hda_remove(struct platform_device *pdev)
#1 lore raw

Hello Myeonghun,

Quoted 9 lines · Myeonghun Pak

sti_hda_probe() registers its bridge before adding the component. If component_add() fails, probe returns the error directly 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 so the probe error path matches the successful-probe remove path.

Duplicate of [0]?

[0] https://lore.kernel.org/all/[email protected]/

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#2 lore raw

Hello Luca,

Yes, this is a duplicate. I missed Osama's patch when preparing mine.

Please ignore/drop my patch, and sorry for the noise.

Thanks,
Myeonghun

2026년 4월 27일 (월) 오후 10:02, Luca Ceresoli <[email protected]>님이 작성:

Quoted 25 lines

Hello Myeonghun,

Quoted 9 lines · Myeonghun Pak

sti_hda_probe() registers its bridge before adding the component. If component_add() fails, probe returns the error directly 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 so the probe error path matches the successful-probe remove path.

Duplicate of [0]?

[0]
https://lore.kernel.org/all/[email protected]/

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com