From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/amd/ras: Fix type size of remainder argument
Date: Fri, 27 Feb 2026 13:07:15 +1000 [thread overview]
Message-ID: <review-patch1-20260225174702.it.918-kees@kernel.org> (raw)
In-Reply-To: <20260225174702.it.918-kees@kernel.org>
Patch Review
**Problem analysis:** The original code at line 72:
```c
int days, remaining_seconds;
days = div64_u64_rem(timestamp, seconds_per_day, (uint64_t *)&remaining_seconds);
```
`div64_u64_rem()` takes a `u64 *remainder` parameter (confirmed in `include/linux/math64.h:54`) and writes 8 bytes through it. But `remaining_seconds` is `int` (4 bytes). The cast `(uint64_t *)&remaining_seconds` silences the compiler but creates two real bugs:
1. **Stack corruption**: 4 bytes of adjacent stack are overwritten.
2. **Endianness bug**: On big-endian systems, the meaningful lower 32 bits of the remainder end up in the wrong half.
**Fix analysis:** The patch introduces a properly-typed `u64 remainder` temporary:
```c
uint64_t month = 0, day = 0, hour = 0, minute = 0, second = 0, remainder;
...
days = div64_u64_rem(timestamp, seconds_per_day, &remainder);
/* remainder will always be less than seconds_per_day. */
remaining_seconds = remainder;
```
This is the right approach for v2. The v1 presumably changed `remaining_seconds` itself to `u64`, which would then require `do_div()` or similar at the later division sites (lines 98-100). By using a temporary and assigning back to `int`, the subsequent arithmetic on `remaining_seconds` stays as native `int` division — no 64-bit division helpers needed.
**Comment on the comment:** The inline comment `/* remainder will always be less than seconds_per_day. */` is helpful — it justifies the narrowing assignment. `seconds_per_day` is 86400, well within `int` range, so the truncation is safe.
**One minor observation:** `days` is also `int` (32-bit) and receives the return value of `div64_u64_rem()`, which returns `u64`. For a Unix timestamp, this quotient is the number of days since epoch — currently ~20,500 and growing. An `int` can hold up to ~2.1 billion days, so this is safe in practice, but it's a preexisting issue and outside the scope of this patch.
**Verdict:** The fix is correct, well-motivated, and minimal. The Fixes tag correctly references the commit that introduced the buggy code. No issues found.
Reviewed-by quality: **Good to merge as-is.**
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-02-27 3:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 17:47 [PATCH v2] drm/amd/ras: Fix type size of remainder argument Kees Cook
2026-02-26 16:46 ` Alex Deucher
2026-02-27 3:07 ` Claude Code Review Bot [this message]
2026-02-27 3:07 ` Claude review: " Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-02-25 1:43 [PATCH] " Kees Cook
2026-02-27 4:18 ` Claude review: " Claude Code Review Bot
2026-02-27 4:18 ` 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-20260225174702.it.918-kees@kernel.org \
--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