From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: staging: fbtft: Use sysfs_emit_at() to print to sysfs file
Date: Thu, 04 Jun 2026 11:55:20 +1000 [thread overview]
Message-ID: <review-patch1-ah_Y_Y2RtqeGxchF@stanley.mountain> (raw)
In-Reply-To: <ah_Y_Y2RtqeGxchF@stanley.mountain>
Patch Review
**The bug:** In `sprintf_gamma()` at line 101, the original code passes `PAGE_SIZE` as the size limit to `scnprintf()`:
```c
len += scnprintf(&buf[len], PAGE_SIZE,
"%04x ", curves[i * par->gamma.num_values + j]);
```
Since the write starts at `&buf[len]`, the correct limit should be `PAGE_SIZE - len`. Passing the full `PAGE_SIZE` means `scnprintf` thinks it has more buffer space than actually remains, which could theoretically write past the end of the page-sized sysfs buffer.
**The fix:** Replaces this with `sysfs_emit_at(buf, len, ...)`:
```c
len += sysfs_emit_at(buf, len,
"%04x ", curves[i * par->gamma.num_values + j]);
```
`sysfs_emit_at()` internally computes `PAGE_SIZE - offset` for the limit and also adds safety checks (page-alignment verification, offset bounds checking), making it the correct and idiomatic API for sysfs show callbacks.
**Correctness:** Verified that this is indeed a sysfs context — `sprintf_gamma()` is called from `show_gamma_curve()` (line 142), which is the show callback registered via `__ATTR(gamma, 0660, show_gamma_curve, store_gamma_curve)` at line 146. The companion function `show_debug()` at line 198 already uses `sysfs_emit()`, so this change also improves consistency within the file.
**Practical impact:** As the commit message correctly notes, the max output is `FBTFT_GAMMA_MAX_VALUES_TOTAL` (128) u32 values formatted as `"%04x "` (5 chars each) = ~640 bytes, well under `PAGE_SIZE` (4096). So this is a correctness fix rather than a security-critical one, but still worth having.
**No issues found.** Reviewed-by worthy.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-06-04 1:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 7:34 [PATCH] staging: fbtft: Use sysfs_emit_at() to print to sysfs file Dan Carpenter
2026-06-03 7:49 ` Andy Shevchenko
2026-06-03 12:48 ` David Laight
2026-06-04 1:55 ` Claude Code Review Bot [this message]
2026-06-04 1:55 ` 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-ah_Y_Y2RtqeGxchF@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