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/amdkfd: convert CRIU event-private allocation to kvcalloc()
Date: Thu, 04 Jun 2026 13:42:10 +1000	[thread overview]
Message-ID: <review-patch1-20260601195510.639318-1-william@theesfeld.net> (raw)
In-Reply-To: <20260601195510.639318-1-william@theesfeld.net>

Patch Review

**Status: Clean / No issues**

The change at `drivers/gpu/drm/amd/amdkfd/kfd_events.c:551`:

```c
- ev_privs = kvzalloc(num_events * sizeof(*ev_privs), GFP_KERNEL);
+ ev_privs = kvcalloc(num_events, sizeof(*ev_privs), GFP_KERNEL);
```

**Correctness:**
- `kvcalloc(n, size, flags)` is functionally equivalent to `kvzalloc(n * size, flags)` but with overflow protection. Both zero the allocated memory. The semantics are preserved.
- `num_events` is a `uint32_t` and `sizeof(*ev_privs)` is a `size_t`, so the multiplication *could* overflow on 32-bit platforms with a sufficiently large `num_events` value. In practice `num_events` comes from `kfd_get_num_events()` which counts IDR entries, so it's bounded by resource limits, but the overflow-safe API is still the right thing to use.
- The `kvfree()` at line 603 remains correct for memory allocated by either `kvzalloc` or `kvcalloc`.

**Observation:** Lines 595 and 601 still use `num_events * sizeof(*ev_privs)` in the open-coded form (for `copy_to_user` and the offset bump). These are not allocation calls so `kvcalloc` doesn't apply, but if the author wanted to be thorough about overflow protection, those multiplications could also use `size_mul()`. This is not a blocker — it's a separate concern and arguably overkill for a size that was already validated at allocation time.

**Commit message:** Accurate and well-written. Correctly notes "no functional change."

Reviewed-by: would be appropriate here.

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-06-04  3:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 19:55 [PATCH] drm/amdkfd: convert CRIU event-private allocation to kvcalloc() William Theesfeld
2026-06-03 16:16 ` Kuehling, Felix
2026-06-04  3:42 ` Claude Code Review Bot [this message]
2026-06-04  3:42 ` 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-20260601195510.639318-1-william@theesfeld.net \
    --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