From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/lease: cap object_count to avoid order > MAX_PAGE_ORDER warning
Date: Wed, 27 May 2026 15:13:21 +1000 [thread overview]
Message-ID: <review-patch1-20260526055359.17392-1-devnexen@gmail.com> (raw)
In-Reply-To: <20260526055359.17392-1-devnexen@gmail.com>
Patch Review
**Correctness: Good.** The check is placed after `cl->object_count` is read into `object_count` (line 514) and before it's used for the `memdup_array_user` call (line 525) and passed to `fill_object_idr` → `kzalloc_objs` (line 389). The `goto out_lessor` target correctly drops the `drm_master` reference obtained at line 506. The fix prevents both the `kzalloc_objs` allocation (array of pointers, 8 bytes each on 64-bit → 4096 * 8 = 32KB, well within a single page order) and the `memdup_array_user` allocation (4096 * 4 = 16KB) from going overboard.
**Nit 1 — Format specifier mismatch:**
```c
drm_dbg_lease(dev, "object_count %zu exceeds max %u\n",
object_count, DRM_MAX_LEASE_OBJECTS);
```
`object_count` is `size_t` so `%zu` is correct for it. `DRM_MAX_LEASE_OBJECTS` is `4096` which is an `int` constant, so `%u` works but `%d` would be more conventional for a plain integer literal. This is not a bug, just a minor style point — either is fine.
**Nit 2 — Limit derivation vs. hard-coded constant.** The value `4096` is chosen to sit below the `MAX_PAGE_ORDER` threshold. A more self-documenting approach would derive the limit from the actual allocation size, e.g.:
```c
#define DRM_MAX_LEASE_OBJECTS \
((PAGE_SIZE << MAX_PAGE_ORDER) / sizeof(struct drm_mode_object *))
```
That said, the hard-coded `4096` is generous enough for any realistic use (real leases have a handful of objects) and simple to understand. The comment explains the rationale. This is a matter of taste, not correctness.
**Nit 3 — `unlikely()` annotation.** The `unlikely()` on line 515 is fine and conventional for error-path guards on ioctl inputs, though opinions vary on whether the branch predictor needs the hint here. No issue.
**Nit 4 — Placement of the `#define`.** The `DRM_MAX_LEASE_OBJECTS` macro is placed between `fill_object_idr()` and `drm_mode_create_lease_ioctl()` in the middle of the file. Placing it near the top of the file with other constants or near the include block would be slightly more conventional, but this is minor.
**Overall:** The patch is correct, well-targeted, and addresses the reported syzbot issue cleanly. The commit message is clear and includes appropriate tags (Reported-by, Closes, Fixes, Signed-off-by). Good to merge with or without the nits addressed.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-27 5:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 5:53 [PATCH] drm/lease: cap object_count to avoid order > MAX_PAGE_ORDER warning David Carlier
2026-05-27 5:13 ` Claude Code Review Bot [this message]
2026-05-27 5:13 ` 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-20260526055359.17392-1-devnexen@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