From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/blend: size zpos array to active planes instead of total
Date: Tue, 05 May 2026 09:43:21 +1000 [thread overview]
Message-ID: <review-patch1-20260501001301.7666-2-gustavopiazdasilva2102@gmail.com> (raw)
In-Reply-To: <20260501001301.7666-2-gustavopiazdasilva2102@gmail.com>
Patch Review
**Correctness:** The change is correct. Walking the function at `drm_blend.c:463-511`:
- `total_planes = hweight32(crtc_state->plane_mask)` — counts exactly the bits set in the mask.
- `kmalloc_objs(*states, total_planes)` at line 477 — allocates that many entries.
- `drm_for_each_plane_mask(plane, dev, crtc_state->plane_mask)` at line 485 — iterates exactly over those same bits.
- `states[n++] = plane_state` at line 492 — `n` will reach exactly `total_planes` (assuming no early error exit), so no overrun.
The zero-planes edge case (`plane_mask == 0`) is also fine: `kmalloc_array(0, ...)` returns `ZERO_SIZE_PTR` (non-NULL), the loop body never executes, `sort` and the for-loop with `n=0` are no-ops, and `kfree(ZERO_SIZE_PTR)` is valid.
**Suggested improvement:** Consider using `hweight_long()` or a type-matched weight function instead of `hweight32()` to avoid a silent truncation bug if `plane_mask` is ever widened beyond `u32`:
```c
- int total_planes = hweight32(crtc_state->plane_mask);
+ int total_planes = hweight_long(crtc_state->plane_mask);
```
Or alternatively, add a static assertion:
```c
BUILD_BUG_ON(sizeof(crtc_state->plane_mask) != sizeof(u32));
```
**Commit message:** The commit message is well written and clearly explains both the problem and the solution. The claim about "reducing memory pressure" is a bit strong for what amounts to saving a few pointers per atomic commit — "tightens the allocation" or "avoids over-allocation" would be more proportionate.
**Verdict:** Correct, low-risk change. Worth applying, ideally with `hweight_long()` for future-proofing.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-04 23:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 0:12 [PATCH 0/1] drm/blend: size zpos array to active planes instead of total Gustavo Piaz Da Silva
2026-05-01 0:13 ` [PATCH 1/1] " Gustavo Piaz Da Silva
2026-05-04 23:43 ` Claude Code Review Bot [this message]
2026-05-04 23:43 ` 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-20260501001301.7666-2-gustavopiazdasilva2102@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