From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/atomic: Return user readable error in atomic_ioctl
Date: Wed, 11 Feb 2026 16:31:47 +1000 [thread overview]
Message-ID: <review-patch5-20260210-atomic-v9-5-525c88fd2402@intel.com> (raw)
In-Reply-To: <20260210-atomic-v9-5-525c88fd2402@intel.com>
Patch Review
**Issues:**
```c
+ if (!arg->reserved)
+ drm_dbg_atomic(dev,
+ "memory not allocated for drm_atomic error reporting\n");
+ else
+ /* Update the error code if any error to allow user handling it */
+ error_code_ptr = (struct drm_mode_atomic_err_code __user *)
+ (unsigned long)arg->reserved;
```
- **No Validation**: Userspace pointer is blindly trusted. No `access_ok()` check.
- **Comment After else**: Comment should explain what happens, not repeat what code does
- **Double Cast**: The `(unsigned long)` cast is unnecessary noise
```c
+ memset(&state->error_code, 0, sizeof(*error_code_ptr));
```
- **Size Mismatch**: Using `sizeof(*error_code_ptr)` (userspace size) to clear kernel's `state->error_code`. Should be `sizeof(state->error_code)`. These happen to be the same type, but the pattern is wrong.
```c
if (!file_priv->atomic) {
+ drm_mode_atomic_add_error_msg(&state->error_code,
+ DRM_MODE_ATOMIC_INVALID_API_USAGE,
+ "drm atomic capability not enabled");
drm_dbg_atomic(dev,
"commit failed: atomic cap not enabled\n");
```
- **Duplication**: Error message is duplicated between `add_error_msg` and `drm_dbg_atomic`. The `drm_dbg_atomic` call inside `add_error_msg` already logs.
```c
if (arg->flags & ~DRM_MODE_ATOMIC_FLAGS) {
- drm_dbg_atomic(dev, "commit failed: invalid flag\n");
- ret = -EINVAL;
- goto out;
- }
-
- if (arg->reserved) {
- drm_dbg_atomic(dev, "commit failed: reserved field set\n");
```
- **Logic Error**: The removal of `arg->reserved` check means old code that validated reserved==0 is gone. This is an ABI break.
```c
+out:
+ /* Update the error code if any error to allow user handling it */
+ if (ret < 0 && arg->reserved) {
+ if (copy_to_user(error_code_ptr, &state->error_code,
+ sizeof(state->error_code)))
+ return -EFAULT;
+ }
```
- **Cleanup Leak**: Returning -EFAULT directly bypasses remaining cleanup code (modeset locks, state free). Should set `ret = -EFAULT;` and fall through.
- **Error Path**: If `copy_to_user` fails, we're already in an error path and now leaking more resources.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-02-11 6:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 9:03 [PATCH v9 0/7] User readable error codes on atomic_ioctl failure Arun R Murthy
2026-02-10 9:03 ` [PATCH v9 1/7] drm: Define user readable error codes for atomic ioctl Arun R Murthy
2026-02-11 6:31 ` Claude review: " Claude Code Review Bot
2026-02-10 9:03 ` [PATCH v9 2/7] drm/atomic: Add error_code element in atomic_state Arun R Murthy
2026-02-11 6:31 ` Claude review: " Claude Code Review Bot
2026-02-10 9:03 ` [PATCH v9 3/7] drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl Arun R Murthy
2026-02-11 6:31 ` Claude review: " Claude Code Review Bot
2026-02-10 9:03 ` [PATCH v9 4/7] drm/atomic: Call complete_signaling only if prepare_signaling is done Arun R Murthy
2026-02-11 6:31 ` Claude review: " Claude Code Review Bot
2026-02-10 9:03 ` [PATCH v9 5/7] drm/atomic: Return user readable error in atomic_ioctl Arun R Murthy
2026-02-11 6:31 ` Claude Code Review Bot [this message]
2026-02-10 9:04 ` [PATCH v9 6/7] drm/i915/display: Error codes for async flip failures Arun R Murthy
2026-02-11 6:31 ` Claude review: " Claude Code Review Bot
2026-02-10 9:04 ` [PATCH v9 7/7] drm: Introduce DRM_CAP_ATOMIC_ERROR_REPORTING Arun R Murthy
2026-02-11 6:31 ` Claude review: " Claude Code Review Bot
2026-02-11 6:31 ` Claude review: User readable error codes on atomic_ioctl failure 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-patch5-20260210-atomic-v9-5-525c88fd2402@intel.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