From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/etnaviv: use kzalloc_flex
Date: Sun, 22 Mar 2026 03:59:28 +1000 [thread overview]
Message-ID: <review-patch1-20260320010757.32158-1-rosenp@gmail.com> (raw)
In-Reply-To: <20260320010757.32158-1-rosenp@gmail.com>
Patch Review
**Correctness: OK**
The conversion is semantically correct:
- The old code computed the size manually via `size_vstruct(nr_bos, sizeof(submit->bos[0]), sizeof(*submit))` and passed it to `kzalloc(sz, GFP_KERNEL)`.
- The new code `kzalloc_flex(*submit, bos, nr_bos)` expands (via `__alloc_flex`) to use `struct_size_t()` for the same computation, and `default_gfp()` with no extra args defaults to `GFP_KERNEL` — matching the original behavior.
- `bos` is indeed the trailing flexible array member of `struct etnaviv_gem_submit` (declared as `struct etnaviv_gem_submit_bo bos[];` at `etnaviv_gem.h:108`).
- The removed `size_vstruct()` has no other callers in the etnaviv driver after this change, so its removal is safe.
**Overflow handling difference (minor):** The old `size_vstruct()` returned 0 on overflow, which would cause `kzalloc(0, GFP_KERNEL)` to return `ZERO_SIZE_PTR` — a non-NULL pointer that faults on dereference (a latent bug, though practically unreachable). The new `kzalloc_flex` uses `struct_size_t()` which returns `SIZE_MAX` on overflow, causing `kzalloc` to return NULL — which is actually the safer and correct behavior. So this is a minor improvement.
**Additional benefit:** `__alloc_flex` also calls `__set_flex_counter()` which, if the `bos` member is annotated with `__counted_by()`, will automatically set the counter field. This is a nice bonus for future hardening.
**Nit:** The commit message says "A local helper was developed previously for struct_size" — this is slightly inaccurate; the helper (`size_vstruct`) predates `struct_size` and is a hand-rolled size calculation, not built on `struct_size`. The message could be clearer, but it's not a blocking issue.
**Reviewed-by worthy: Yes.** The patch is a clean, correct conversion to the preferred kernel API.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-21 17:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 1:07 [PATCH] drm/etnaviv: use kzalloc_flex Rosen Penev
2026-03-21 17:59 ` Claude Code Review Bot [this message]
2026-03-21 17:59 ` 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-20260320010757.32158-1-rosenp@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