From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/amdgpu: Fix potential out-of-bounds access in 'amdgpu_discovery_reg_base_init()'
Date: Wed, 25 Mar 2026 08:02:38 +1000 [thread overview]
Message-ID: <review-patch1-20260323071052.4068410-1-1468888505@139.com> (raw)
In-Reply-To: <20260323071052.4068410-1-1468888505@139.com>
Patch Review
**The fix is correct in principle** — it moves the bounds check before the array write, preventing OOB access. However, there is a subtle behavioral difference from the upstream version:
**Issue 1: `ip->revision &= ~0xc0` moved outside the bounds check**
In the original (pre-fix) code:
```c
adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
ip->revision & 0xc0;
ip->revision &= ~0xc0;
if (adev->vcn.num_vcn_inst < AMDGPU_MAX_VCN_INSTANCES)
adev->vcn.num_vcn_inst++;
```
The `ip->revision &= ~0xc0` clearing always happened regardless of bounds. In the patched code:
```c
if (adev->vcn.num_vcn_inst < AMDGPU_MAX_VCN_INSTANCES) {
adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
ip->revision & 0xc0;
adev->vcn.num_vcn_inst++;
} else
...
ip->revision &= ~0xc0;
```
The `ip->revision &= ~0xc0` is placed **after** the if/else, so it still executes unconditionally in both paths. This is correct and preserves the original semantics.
**Issue 2: Missing `inst_mask` updates compared to upstream**
Looking at the current upstream code (drm-next), the fix there also sets `adev->vcn.inst_mask` and `adev->jpeg.inst_mask` inside the bounds-checked block, and the field was refactored from `adev->vcn.vcn_config[]` to `adev->vcn.inst[].vcn_config`. These differences are expected since this is a 6.1.y backport targeting an older kernel with a different data structure, so this is fine.
**Issue 3: Style nit — asymmetric braces**
```c
if (adev->vcn.num_vcn_inst < AMDGPU_MAX_VCN_INSTANCES) {
...
} else
dev_err(...);
```
Per kernel coding style, when one branch of an if/else uses braces, both should. This should be:
```c
} else {
dev_err(...);
}
```
This is a minor style issue that was actually present in the original code too (the `else` branch had no braces), so it's not a regression from this patch.
**Verdict**: The backport is functionally correct and appropriate for 6.1.y stable. The OOB fix is sound — the array write is now properly guarded. The conflict resolution appears to have been done correctly, preserving the original semantics of always clearing the revision bits. No functional concerns.
---
Generated by Claude Code Patch Reviewer
prev parent reply other threads:[~2026-03-24 22:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 7:10 [PATCH 6.1.y] drm/amdgpu: Fix potential out-of-bounds access in 'amdgpu_discovery_reg_base_init()' Li hongliang
2026-03-23 9:51 ` Christian König
2026-03-23 10:32 ` Greg KH
2026-03-23 12:28 ` Christian König
2026-03-23 12:37 ` Greg KH
2026-03-24 0:52 ` Re:Re: [PATCH 6.1.y] drm/amdgpu: Fix potential out-of-bounds access in'amdgpu_discovery_reg_base_init()' 18801328227
2026-03-24 22:02 ` Claude review: drm/amdgpu: Fix potential out-of-bounds access in 'amdgpu_discovery_reg_base_init()' Claude Code Review Bot
2026-03-24 22:02 ` 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-20260323071052.4068410-1-1468888505@139.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