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: use checked access in `FwSecBiosImage::header` Date: Sun, 12 Apr 2026 10:18:46 +1000 Message-ID: In-Reply-To: <20260410-fix-vbios-v1-4-bc6f71d153d6@nvidia.com> References: <20260410-fix-vbios-v1-0-bc6f71d153d6@nvidia.com> <20260410-fix-vbios-v1-4-bc6f71d153d6@nvidia.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review This patch moves the `data.get(falcon_ucode_offset..)` call to happen first= , then uses `data.get(..4)` instead of direct slicing to read the version h= eader: ```rust + let data =3D self.base.data.get(falcon_ucode_offset..).ok_or(EINVA= L)?; + // Read the first 4 bytes to get the version. - let hdr_bytes: [u8; 4] =3D self.base.data[falcon_ucode_offset..fal= con_ucode_offset + 4] + let hdr_bytes: [u8; 4] =3D data + .get(..4) + .ok_or(EINVAL)? .try_into() .map_err(|_| EINVAL)?; ``` Looking at the original code, the `.get(falcon_ucode_offset..)` call alread= y existed but was placed *after* the unchecked `self.base.data[falcon_ucode= _offset..falcon_ucode_offset + 4]` =E2=80=94 so the old code would panic on= an out-of-bounds `falcon_ucode_offset` before ever reaching the checked ac= cess. This patch correctly reorders the operations and makes both accesses = checked. Note: the `.try_into().map_err(|_| EINVAL)?` after `.get(..4).ok_or(EINVAL)= ?` is now technically redundant since `.get(..4)` on a slice guarantees exa= ctly 4 bytes (or `None`). But it's harmless and the compiler will optimize = it away, so no issue. **Reviewed-by assessment: Good.** --- --- Generated by Claude Code Patch Reviewer