public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/sun4i: Fix resource leaks
@ 2026-02-26 16:38 Ethan Tidmore
  2026-02-27  1:44 ` Claude review: " Claude Code Review Bot
  2026-02-27  1:44 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Ethan Tidmore @ 2026-02-26 16:38 UTC (permalink / raw)
  To: wens, mripard, jernej.skrabec, samuel
  Cc: maarten.lankhorst, tzimmermann, airlied, simona, dri-devel,
	linux-arm-kernel, linux-sunxi, linux-kernel, Ethan Tidmore

Three clocks are not being released in devm_regmap_init_mmio() error
path.

Add proper goto and set ret to the error code.

Fixes: 8270249fbeaf0 ("drm/sun4i: backend: Create regmap after access is possible")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 6391bdc94a5c..e989f75c09b7 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -881,7 +881,8 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
 						     &sun4i_backend_regmap_config);
 	if (IS_ERR(backend->engine.regs)) {
 		dev_err(dev, "Couldn't create the backend regmap\n");
-		return PTR_ERR(backend->engine.regs);
+		ret = PTR_ERR(backend->engine.regs);
+		goto err_disable_ram_clk;
 	}
 
 	list_add_tail(&backend->engine.list, &drv->engine_list);
-- 
2.53.0


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

* Claude review: drm/sun4i: Fix resource leaks
  2026-02-26 16:38 [PATCH] drm/sun4i: Fix resource leaks Ethan Tidmore
@ 2026-02-27  1:44 ` Claude Code Review Bot
  2026-02-27  1:44 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-02-27  1:44 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/sun4i: Fix resource leaks
Author: Ethan Tidmore <ethantidmore06@gmail.com>
Patches: 1
Reviewed: 2026-02-27T11:44:46.295713

---

This is a single-patch submission fixing a resource leak in the sun4i display backend driver. The fix is **correct and straightforward**: when `devm_regmap_init_mmio()` fails, the original code returned directly, leaking three clocks (bus_clk, mod_clk, ram_clk) and leaving the reset control deasserted. The patch properly sets `ret` and jumps to the existing `err_disable_ram_clk` cleanup label, which chains through all necessary cleanup.

The patch is minimal, well-targeted, and has an appropriate Fixes tag. There is one minor observation about a pre-existing issue worth noting, but it does not affect the correctness of this patch.

**Verdict: Patch looks good.**

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/sun4i: Fix resource leaks
  2026-02-26 16:38 [PATCH] drm/sun4i: Fix resource leaks Ethan Tidmore
  2026-02-27  1:44 ` Claude review: " Claude Code Review Bot
@ 2026-02-27  1:44 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-02-27  1:44 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**The bug:** In `sun4i_backend_bind()`, at the point where `devm_regmap_init_mmio()` is called (line 877), the following non-devm resources have already been acquired:
1. Reset deasserted (`reset_control_deassert` at line 831)
2. `bus_clk` enabled (`clk_prepare_enable` at line 843)
3. `mod_clk` rate set exclusively and enabled (lines 852, 858)
4. `ram_clk` enabled (`clk_prepare_enable` at line 866)

The original code did a bare `return PTR_ERR(backend->engine.regs)`, skipping all cleanup.

**The fix is correct:**

```c
-		return PTR_ERR(backend->engine.regs);
+		ret = PTR_ERR(backend->engine.regs);
+		goto err_disable_ram_clk;
```

The `err_disable_ram_clk` label at line 932 chains through all the necessary cleanup in proper reverse order:
```c
err_disable_ram_clk:
	clk_disable_unprepare(backend->ram_clk);
err_disable_mod_clk:
	clk_rate_exclusive_put(backend->mod_clk);
	clk_disable_unprepare(backend->mod_clk);
err_disable_bus_clk:
	clk_disable_unprepare(backend->bus_clk);
err_assert_reset:
	reset_control_assert(backend->reset);
	return ret;
```

This correctly releases all four resources that were acquired.

**Minor nit on commit message:** The commit message says "Three clocks are not being released" — this is accurate for the clocks, but the reset control (`backend->reset`) is also leaked by the direct return. The fix handles this correctly via the goto chain, but the commit message could be more precise (e.g., "Three clocks and a reset control are not being released"). This is cosmetic.

**Pre-existing issue (not introduced by this patch):** On `sun8i-a33` devices, `sun4i_backend_init_sat()` is called just before the regmap init (line 870). If SAT init succeeds but regmap init subsequently fails, jumping to `err_disable_ram_clk` does not call `sun4i_backend_free_sat()`, leaking the SAT clock and reset. This is a separate pre-existing bug — the patch correctly uses the same goto target that SAT init failure itself uses — but the author may want to address it as a follow-up.

---
Generated by Claude Code Patch Reviewer

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

end of thread, other threads:[~2026-02-27  1:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 16:38 [PATCH] drm/sun4i: Fix resource leaks Ethan Tidmore
2026-02-27  1:44 ` Claude review: " Claude Code Review Bot
2026-02-27  1:44 ` 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