From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm: renesas: rz-du: mipi_dsi: Fix return path on error
Date: Thu, 23 Apr 2026 07:31:41 +1000 [thread overview]
Message-ID: <review-patch1-20260422145146.1638998-1-chris.brandt@renesas.com> (raw)
In-Reply-To: <20260422145146.1638998-1-chris.brandt@renesas.com>
Patch Review
**The bug (confirmed in tree):** In the current code at line 1476-1479 of `rzg2l_mipi_dsi.c`:
```c
dsi->dcs_buf_virt = dma_alloc_coherent(dsi->host.dev, RZG2L_DCS_BUF_SIZE,
&dsi->dcs_buf_phys, GFP_KERNEL);
if (!dsi->dcs_buf_virt)
return -ENOMEM;
```
This bare `return -ENOMEM` leaks two resources:
1. The `mipi_dsi_host_register` at line 1472 is never unregistered.
2. The `pm_runtime_enable` at line 1446 is never disabled.
**The fix is correct and clean:**
1. **`dma_alloc_coherent` → `dmam_alloc_coherent`**: The managed variant ties the DMA buffer lifetime to the device via devres, so no explicit free is needed. This eliminates the `dma_free_coherent` call in `rzg2l_mipi_dsi_remove`, which is correct.
2. **Moving allocation before `platform_set_drvdata` / `pm_runtime_enable`**: At this point in probe, only `devm_`-managed resources (clocks, resets, ioremap) have been acquired. A plain `return -ENOMEM` is safe here — all prior allocations are device-managed and will be cleaned up automatically. The DMA buffer isn't used until actual DSI host transfers, so early allocation is fine.
3. **Device parameter change**: The original used `dsi->host.dev`, the new code uses `dsi->dev`. This is correct because `dsi->host.dev` hasn't been assigned yet at the new call site, and they are set to the same value anyway (line 1470: `dsi->host.dev = dsi->dev`).
**Minor observations (not blocking):**
- The commit message could be slightly more explicit about *what* was leaking (host registration + pm_runtime), but "unwind correctly" is adequate for a Fixes patch.
- The ordering in `remove` now has `mipi_dsi_host_unregister` first and `pm_runtime_disable` second, with the DMA free handled by devres (which runs after `remove` returns). This ordering is correct — devres cleanup happens during device unbind after the driver's remove callback.
**No issues found. Patch is ready.**
Reviewed-by: Dave Airlie <airlied@gmail.com>
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-04-22 21:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 14:51 [PATCH v2] drm: renesas: rz-du: mipi_dsi: Fix return path on error Chris Brandt
2026-04-22 15:02 ` Hugo Villeneuve
2026-04-22 21:31 ` Claude review: " Claude Code Review Bot
2026-04-22 21:31 ` Claude Code Review Bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-05-01 13:21 [PATCH v3] " Chris Brandt
2026-05-04 23:27 ` Claude review: " Claude Code Review Bot
2026-05-04 23:27 ` 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-20260422145146.1638998-1-chris.brandt@renesas.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