From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm: zynqmp_dp: Fix uninitialized variable in debugfs()
Date: Tue, 26 May 2026 07:37:39 +1000 [thread overview]
Message-ID: <review-patch1-ahP3Xagt1LJrhmFl@stanley.mountain> (raw)
In-Reply-To: <ahP3Xagt1LJrhmFl@stanley.mountain>
Patch Review
**Analysis of the bug:**
`simple_write_to_buffer()` writes to `to + pos` where `pos = *ppos`. If `*ppos` is non-zero, the beginning of the stack-allocated buffer is never initialized. This affects both functions:
1. **`zynqmp_dp_pattern_write()`** — the uninitialized prefix bytes in `buf` are followed by `buf[ret] = '\0'` and then `sysfs_match_string()`. The match would operate on garbage bytes at the start of the string.
2. **`zynqmp_dp_custom_write()`** — `memcpy(dp->test.custom, buf, ret)` copies from the beginning of `buf`, which includes uninitialized bytes when `*ppos` was non-zero. This leaks stack contents into `dp->test.custom`, which is then written to hardware via `zynqmp_dp_set_test_pattern()`.
**The fix:**
```c
if (*ppos != 0)
return -EINVAL;
```
Added at the top of both write functions. This is the standard kernel pattern for debugfs write handlers that expect a single complete write. Both `file_operations` structs use `noop_llseek`, confirming these are not designed for seekable I/O.
**Review comments:**
- **Correct and complete.** Both affected write handlers are fixed.
- **Appropriate error code.** `-EINVAL` is the right choice for rejecting an invalid ppos.
- **Behavioral note:** After a successful write, `simple_write_to_buffer()` advances `*ppos`, so a second `write()` on the same fd will now return `-EINVAL` instead of the previous behavior (returning `0` when `*ppos >= available`). This is actually an improvement — `-EINVAL` is more informative than a silent zero-length write.
- **Fixes tag** correctly references the commit that introduced the debugfs interface.
**No issues found.**
Reviewed-by worthy as-is.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-05-25 21:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 7:16 [PATCH] drm: zynqmp_dp: Fix uninitialized variable in debugfs() Dan Carpenter
2026-05-25 21:37 ` Claude review: " Claude Code Review Bot
2026-05-25 21:37 ` 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-patch1-ahP3Xagt1LJrhmFl@stanley.mountain \
--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