From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: gpu: nova-core: vbios: limit `BitToken` entry reads Date: Sun, 12 Apr 2026 10:18:46 +1000 Message-ID: In-Reply-To: <20260410-fix-vbios-v1-2-bc6f71d153d6@nvidia.com> References: <20260410-fix-vbios-v1-0-bc6f71d153d6@nvidia.com> <20260410-fix-vbios-v1-2-bc6f71d153d6@nvidia.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review This patch adds a check that `header.token_size >= size_of::()` and replaces direct array indexing with `.get()` + `.ok_or(EINVAL)?`. ```rust + if entry_size < size_of::() { + return Err(EINVAL); ``` This is a correct and important check. If the firmware reports a `token_size` smaller than the `BitToken` struct (6 bytes), the old code would index out of bounds within each entry. The refactored loop body: ```rust + let entry = image + .base + .data + .get(entry_offset..) + .and_then(|data| data.get(..entry_size)) + .ok_or(EINVAL)?; ``` This is cleaner than the old bounds check + direct indexing. The subsequent access to `entry[0]` through `entry[5]` is safe because `entry_size >= size_of::()` (which is 6) was verified up front. Minor: No error message or `dev_err!` is emitted when `entry_size < size_of::()`. The existing code also didn't emit a message for out-of-bounds, so this is consistent. A `dev_err!` might be helpful for debugging bad firmware in the field, but it's not mandatory. **Reviewed-by assessment: Good.** --- --- Generated by Claude Code Patch Reviewer