From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/nouveau/kms: add NULL check for CRTC in nv50_sor_atomic_disable
Date: Sun, 12 Apr 2026 10:25:01 +1000 [thread overview]
Message-ID: <review-patch2-20260409172126.115441-3-marek@czernohous.de> (raw)
In-Reply-To: <20260409172126.115441-3-marek@czernohous.de>
Patch Review
**Verdict: Defensive fix that prevents a crash, but the explanation is suspect and the early-return may skip necessary cleanup.**
The change:
```c
+ if (!nv_encoder->crtc) {
+ nvif_outp_release(&nv_encoder->outp);
+ return;
+ }
+ head = nv50_head(nv_encoder->crtc);
```
**Issue 1: The race condition explanation is dubious.** The commit says: *"a race condition can occur between atomic_check and atomic_commit: the encoder's CRTC reference may become NULL after validation but before the disable callback runs."* In the DRM atomic framework, `atomic_commit` holds all the necessary modeset locks. The `nv_encoder->crtc` field is nouveau's own internal tracking, set at the end of `nv50_sor_atomic_disable` itself (line 1604: `nv_encoder->crtc = NULL`). If `crtc` is NULL entering this function, it is more likely that the encoder was never attached, or that there's a double-disable scenario — not an atomic check/commit race. The commit message should explain the actual root cause or at least describe it as "crtc may be NULL in certain teardown paths" without speculating about a race that the locking should prevent.
**Issue 2: The early return skips significant cleanup.** When `nv_encoder->crtc` is NULL, the function returns after only calling `nvif_outp_release()`. But the full path also does:
- Backlight disable via DPCD (`drm_edp_backlight_disable`)
- HDMI state cleanup (`nvif_outp_hdmi(..., false, ...)`)
- DP power-down (`nouveau_dp_power_down`)
- Display ID clearing (`head->func->display_id(head, 0)`)
- Encoder update and audio disable
Some of these (like DP power-down, backlight disable) operate on the encoder/connector, not the CRTC, and might still be needed even when the CRTC is gone. If the CRTC being NULL is truly expected, the commit should justify why none of that other cleanup matters.
**Issue 3: The note about container_of is correct** — `container_of(NULL, ...)` produces a bogus non-NULL pointer, so the check must be done before calling `nv50_head()`. This is well-explained.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-04-12 0:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 17:21 [PATCH 0/3] drm/nouveau: stability fixes for NVAC (MCP79/MCP7A) Marek Czernohous
2026-04-09 17:21 ` [PATCH 1/3] drm/nouveau/pci: use nv46 MSI rearm for G94 (NVAC/MCP79) Marek Czernohous
2026-04-12 0:25 ` Claude review: " Claude Code Review Bot
2026-04-09 17:21 ` [PATCH 2/3] drm/nouveau/kms: add NULL check for CRTC in nv50_sor_atomic_disable Marek Czernohous
2026-04-12 0:25 ` Claude Code Review Bot [this message]
2026-04-09 17:21 ` [PATCH 3/3] drm/nouveau/dp: retry link check once on HPD IRQ before disconnect Marek Czernohous
2026-04-12 0:25 ` Claude review: " Claude Code Review Bot
2026-04-12 0:25 ` Claude review: drm/nouveau: stability fixes for NVAC (MCP79/MCP7A) 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-patch2-20260409172126.115441-3-marek@czernohous.de \
--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