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-overall-20260501001301.7666-1-gustavopiazdasilva2102@gmail.com> (raw)
In-Reply-To: <20260501001301.7666-1-gustavopiazdasilva2102@gmail.com>
Overall Series Review
Subject: drm/blend: size zpos array to active planes instead of total
Author: Gustavo Piaz Da Silva <gustavopiazdasilva2102@gmail.com>
Patches: 2
Reviewed: 2026-05-05T09:43:21.243447
---
This is a single-patch series that reduces the allocation size of a temporary array in `drm_atomic_helper_crtc_normalize_zpos()` from `num_total_plane` (all planes on the device) to `hweight32(crtc_state->plane_mask)` (only the active planes on the given CRTC).
The change is **correct**. The `drm_for_each_plane_mask()` loop iterates exactly over the bits set in `plane_mask`, so `hweight32(plane_mask)` gives the precise count of array entries that will be populated. The original allocation was safe but conservatively oversized.
That said, the practical benefit is minimal. A typical device might have 3-8 total planes, and each array entry is a single pointer (8 bytes on 64-bit). The savings are on the order of a handful of bytes per CRTC atomic commit — not meaningful "memory pressure." The real value is arguably in making the code more self-documenting: the allocation size now directly reflects the iteration count.
**One potential issue worth flagging:** `plane_mask` is `u32` (confirmed at `include/drm/drm_crtc.h:195`), so `hweight32()` is type-correct today. However, if `plane_mask` were ever widened (e.g., to `u64` for devices with >32 planes), the `hweight32()` call would silently truncate and produce an undersized allocation, causing an out-of-bounds write at line 492:
```c
states[n++] = plane_state;
```
This is not a bug today, but it is a latent fragility the original code didn't have. Using `hweight_long()` or adding a `BUILD_BUG_ON(sizeof(crtc_state->plane_mask) > sizeof(u32))` would harden against that future scenario.
---
---
Generated by Claude Code Patch Reviewer
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 review: " Claude Code Review Bot
2026-05-04 23:43 ` Claude Code Review Bot [this message]
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-overall-20260501001301.7666-1-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