public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/sun4i: Fix resource leaks
Date: Fri, 27 Feb 2026 11:44:46 +1000	[thread overview]
Message-ID: <review-patch1-20260226163836.10335-1-ethantidmore06@gmail.com> (raw)
In-Reply-To: <20260226163836.10335-1-ethantidmore06@gmail.com>

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

  reply	other threads:[~2026-02-27  1:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 16:38 [PATCH] drm/sun4i: Fix resource leaks Ethan Tidmore
2026-02-27  1:44 ` Claude Code Review Bot [this message]
2026-02-27  1:44 ` Claude review: " Claude Code Review Bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch1-20260226163836.10335-1-ethantidmore06@gmail.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox