public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v1] drm/panel: lg-sw43408: remove panel on DSI attach failure
       [not found] <Casey Connolly <casey.connolly@linaro.org>
@ 2026-04-20  7:38 ` Myeonghun Pak
  2026-04-22 19:24   ` Dmitry Baryshkov
                     ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Myeonghun Pak @ 2026-04-20  7:38 UTC (permalink / raw)
  To: Sumit Semwal, Casey Connolly
  Cc: Myeonghun Pak, Neil Armstrong, Jessica Zhang, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	dri-devel, linux-kernel, Ijae Kim, Taegyu Kim, Yuho Choi

The probe path registers the panel by calling drm_panel_add() in
sw43408_add(), then returns the result of mipi_dsi_attach() directly
from sw43408_probe().

If mipi_dsi_attach() fails, the probe path exits without calling
drm_panel_remove(), leaving the panel registered in the global DRM
panel list. The .remove() callback does not cover this case because
it is only invoked after a successful probe.

Fix this by unwinding the panel registration with drm_panel_remove()
when mipi_dsi_attach() fails.

Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Co-developed-by: Taegyu Kim <tmk5904@psu.edu>
Signed-off-by: Taegyu Kim <tmk5904@psu.edu>
Co-developed-by: Yuho Choi <dbgh9129@gmail.com>
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/gpu/drm/panel/panel-lg-sw43408.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-lg-sw43408.c b/drivers/gpu/drm/panel/panel-lg-sw43408.c
index 293826c50..0eb78bc90 100644
--- a/drivers/gpu/drm/panel/panel-lg-sw43408.c
+++ b/drivers/gpu/drm/panel/panel-lg-sw43408.c
@@ -294,7 +294,13 @@ static int sw43408_probe(struct mipi_dsi_device *dsi)
 
 	dsi->dsc = &ctx->dsc;
 
-	return mipi_dsi_attach(dsi);
+	ret = mipi_dsi_attach(dsi);
+	if (ret < 0) {
+		drm_panel_remove(&ctx->base);
+		return ret;
+	}
+
+	return 0;
 }
 
 static void sw43408_remove(struct mipi_dsi_device *dsi)
-- 

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

* Re: [PATCH v1] drm/panel: lg-sw43408: remove panel on DSI attach failure
  2026-04-20  7:38 ` [PATCH v1] drm/panel: lg-sw43408: remove panel on DSI attach failure Myeonghun Pak
@ 2026-04-22 19:24   ` Dmitry Baryshkov
  2026-04-23  0:12   ` Claude review: " Claude Code Review Bot
  2026-04-23  0:12   ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry Baryshkov @ 2026-04-22 19:24 UTC (permalink / raw)
  To: Myeonghun Pak
  Cc: Sumit Semwal, Casey Connolly, Neil Armstrong, Jessica Zhang,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, dri-devel, linux-kernel, Ijae Kim, Taegyu Kim,
	Yuho Choi

On Mon, Apr 20, 2026 at 04:38:27PM +0900, Myeonghun Pak wrote:
> The probe path registers the panel by calling drm_panel_add() in
> sw43408_add(), then returns the result of mipi_dsi_attach() directly
> from sw43408_probe().
> 
> If mipi_dsi_attach() fails, the probe path exits without calling
> drm_panel_remove(), leaving the panel registered in the global DRM
> panel list. The .remove() callback does not cover this case because
> it is only invoked after a successful probe.
> 
> Fix this by unwinding the panel registration with drm_panel_remove()
> when mipi_dsi_attach() fails.
> 
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Co-developed-by: Taegyu Kim <tmk5904@psu.edu>
> Signed-off-by: Taegyu Kim <tmk5904@psu.edu>
> Co-developed-by: Yuho Choi <dbgh9129@gmail.com>
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>  drivers/gpu/drm/panel/panel-lg-sw43408.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 

You can also switch to devm_drm_panel_add().

-- 
With best wishes
Dmitry

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

* Claude review: drm/panel: lg-sw43408: remove panel on DSI attach failure
  2026-04-20  7:38 ` [PATCH v1] drm/panel: lg-sw43408: remove panel on DSI attach failure Myeonghun Pak
  2026-04-22 19:24   ` Dmitry Baryshkov
@ 2026-04-23  0:12   ` Claude Code Review Bot
  2026-04-23  0:12   ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-04-23  0:12 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/panel: lg-sw43408: remove panel on DSI attach failure
Author: Myeonghun Pak <mhun512@gmail.com>
Patches: 2
Reviewed: 2026-04-23T10:12:25.537212

---

This is a single-patch fix for a real resource leak in the LG SW43408 panel driver. When `mipi_dsi_attach()` fails during probe, `drm_panel_add()` has already been called (inside `sw43408_add()`), but `sw43408_remove()` is never invoked because probe failed. This leaves a stale entry in the global DRM panel list. The fix correctly unwinds by calling `drm_panel_remove()` on the attach failure path.

The analysis is sound: `devm_drm_panel_alloc()` handles `drm_panel_put()` via devres, but `drm_panel_add()`/`drm_panel_remove()` is a separate pairing that is not automatically managed. All other resources acquired in `sw43408_add()` (regulators, GPIO, backlight) use `devm_` allocators and need no explicit cleanup.

**Verdict: The patch is correct and should be accepted.**

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/panel: lg-sw43408: remove panel on DSI attach failure
  2026-04-20  7:38 ` [PATCH v1] drm/panel: lg-sw43408: remove panel on DSI attach failure Myeonghun Pak
  2026-04-22 19:24   ` Dmitry Baryshkov
  2026-04-23  0:12   ` Claude review: " Claude Code Review Bot
@ 2026-04-23  0:12   ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-04-23  0:12 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Correctness: Good.** The error handling properly captures the return value of `mipi_dsi_attach()` and calls `drm_panel_remove()` before returning the error:

```c
-	return mipi_dsi_attach(dsi);
+	ret = mipi_dsi_attach(dsi);
+	if (ret < 0) {
+		drm_panel_remove(&ctx->base);
+		return ret;
+	}
+
+	return 0;
```

This correctly mirrors the cleanup done in `sw43408_remove()` (line 309 of the existing file), where `drm_panel_remove(&ctx->base)` is called after `mipi_dsi_detach()`.

**Minor nits:**

1. **Commit message formatting**: The `In-Reply-To:` and `References:` headers contain `<Casey Connolly <casey.connolly@linaro.org>` which is a malformed Message-ID (should be an actual Message-ID like `<xxxx@host>`). This is a mailing list metadata issue, not a code issue, but suggests the patch was sent as a reply to a message without properly quoting the Message-ID.

2. **Style**: `return 0` at the end is fine. An alternative would be `return ret` (since `ret` is 0 on the success path), but the explicit `return 0` is arguably clearer and matches the convention in other panel drivers.

3. **Scope**: The patch is narrowly focused on fixing exactly one bug. No unnecessary changes.

**No issues found with the code change itself.** The fix is minimal, correct, and well-explained in the commit message.

---
Generated by Claude Code Patch Reviewer

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Casey Connolly <casey.connolly@linaro.org>
2026-04-20  7:38 ` [PATCH v1] drm/panel: lg-sw43408: remove panel on DSI attach failure Myeonghun Pak
2026-04-22 19:24   ` Dmitry Baryshkov
2026-04-23  0:12   ` Claude review: " Claude Code Review Bot
2026-04-23  0:12   ` 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