public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/sti: hdmi: remove bridge when component_add fails
@ 2026-04-10 19:41 Osama Abdelkader
  2026-04-11 23:29 ` Claude review: " Claude Code Review Bot
  2026-04-11 23:29 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Osama Abdelkader @ 2026-04-10 19:41 UTC (permalink / raw)
  To: luca.ceresoli, Alain Volmat, Raphael Gallais-Pou,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, dri-devel, linux-kernel
  Cc: Osama Abdelkader

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);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Claude review: drm/sti: hdmi: remove bridge when component_add fails
  2026-04-10 19:41 [PATCH] drm/sti: hdmi: remove bridge when component_add fails Osama Abdelkader
  2026-04-11 23:29 ` Claude review: " Claude Code Review Bot
@ 2026-04-11 23:29 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-04-11 23:29 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/sti: hdmi: remove bridge when component_add fails
Author: Osama Abdelkader <osama.abdelkader@gmail.com>
Patches: 1
Reviewed: 2026-04-12T09:29:49.186001

---

This is a single-patch fix for a resource leak in the `sti_hdmi_probe()` error path. The bug is real: when `component_add()` fails, the previously-added DRM bridge is leaked and the i2c adapter reference is not released. The fix is correct and follows the existing error-handling pattern in the function.

**Verdict: Good fix, minor style nit.**

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Claude review: drm/sti: hdmi: remove bridge when component_add fails
  2026-04-10 19:41 [PATCH] drm/sti: hdmi: remove bridge when component_add fails Osama Abdelkader
@ 2026-04-11 23:29 ` Claude Code Review Bot
  2026-04-11 23:29 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-04-11 23:29 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**The bug is real.** Before this patch, lines 1462-1463 (post-patch numbering) were:

```c
drm_bridge_add(&hdmi->bridge);
return component_add(&pdev->dev, &sti_hdmi_ops);
```

If `component_add()` fails, execution returns directly with the error code, leaking both the `drm_bridge_add()` registration and the `i2c_put_adapter()` reference acquired at line 1392.

**The fix is correct.** The new `remove_bridge` label is placed between the `return 0` and the existing `release_adapter` label, so it properly falls through to also call `i2c_put_adapter()`:

```c
 remove_bridge:
	drm_bridge_remove(&hdmi->bridge);
 release_adapter:
	i2c_put_adapter(hdmi->ddc_adapt);
```

This matches the reverse order of acquisition (`drm_bridge_add` after adapter, so `drm_bridge_remove` before `i2c_put_adapter`).

**Consistency with `sti_hdmi_remove()`.** The remove function at line 1476 calls `drm_bridge_remove()` and `i2c_put_adapter()`, confirming both resources need cleanup — consistent with what this patch does on the error path.

**Minor nit — commit message style.** The commit message body ("when component_add fails in sti_hdmi_probe remove the drm bridge and put i2c adapter before return") is a run-on sentence. A slightly improved version:

> When component_add() fails in sti_hdmi_probe(), the DRM bridge and I2C adapter reference are leaked. Add a cleanup path to call drm_bridge_remove() and i2c_put_adapter() on failure.

This is a style-only suggestion and shouldn't block the patch.

**Reviewed-by worthy:** Yes. The logic is sound, the error unwind order is correct, and the fix is minimal. This is a straightforward resource-leak fix.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-11 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 19:41 [PATCH] drm/sti: hdmi: remove bridge when component_add fails Osama Abdelkader
2026-04-11 23:29 ` Claude review: " Claude Code Review Bot
2026-04-11 23:29 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox