From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/nouveau: handle nouveau_hw_get_clock() return value
Date: Sat, 16 May 2026 10:30:38 +1000 [thread overview]
Message-ID: <review-patch1-20260514174008.4515-1-ms.bulatov7@gmail.com> (raw)
In-Reply-To: <20260514174008.4515-1-ms.bulatov7@gmail.com>
Patch Review
**Correctness concern — uninitialized output parameters on early return:**
```c
if (MClk <= 0 || NVClk <= 0)
return;
```
When this early return is taken, `nv04_update_arb()` never writes to `*burst` or `*lwm`. The only caller path through `nouveau_calc_arb()` reaching this code is in `crtc.c`:
```c
int arb_burst, arb_lwm; /* line 848 — uninitialized */
nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->format->cpp[0] * 8,
&arb_burst, &arb_lwm);
regp->CRTC[NV_CIO_CRE_FF_INDEX] = arb_burst; /* used uninitialized */
regp->CRTC[NV_CIO_CRE_FFLWM__INDEX] = arb_lwm & 0xff; /* used uninitialized */
```
This writes garbage stack data to hardware CRTC registers. The fix should set `*burst` and `*lwm` to safe defaults (e.g., 0) before returning, or the function signature should be changed to return an error that the caller checks.
The simplest fix would be:
```c
if (MClk <= 0 || NVClk <= 0) {
*burst = 0;
*lwm = 0;
return;
}
```
**Minor: the `<= 0` check conflates two cases.** `nouveau_hw_get_clock()` can return:
- `0` — from `nouveau_hw_pllvals_to_clk()` when M1 or M2 is zero
- A negative errno (e.g., `-ENOENT`) — from `nouveau_hw_get_pllvals()` failure
The `<= 0` check correctly catches both, so the logic is sound, but the commit message claims to "fix all this by adding a check" when the real root cause (propagating error codes properly from `nouveau_hw_get_clock`) remains unfixed. This is acceptable for a targeted defensive fix, but worth noting.
**Commit message nit:** The Fixes tag references `6ee738610f41` ("drm/nouveau: Add DRM driver for NVIDIA GPUs"), which is the initial nouveau commit. While technically correct that the bug has existed since then, it would be more useful to reference the commit that introduced this specific code path if one exists, since the Fixes tag drives stable-kernel backport decisions.
**Summary:** The identified bug (division by zero) is real and worth fixing. The patch needs a small revision to initialize the output parameters before the early return to avoid writing uninitialized values to hardware registers.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-05-16 0:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 17:40 [PATCH] drm/nouveau: handle nouveau_hw_get_clock() return value Bulatov Mark
2026-05-16 0:30 ` Claude review: " Claude Code Review Bot
2026-05-16 0:30 ` 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-20260514174008.4515-1-ms.bulatov7@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