Re: [PATCH 4/5] gpu: nova-core: vbios: use checked access in `FwSecBiosImage::header`

Joel Fernandes
2026-04-10T15:00:33Z

On 4/10/2026 4:38 AM, Eliot Courtney wrote:
> Use checked access in `FwSecBiosImage::header` for getting the header
> version since the value is firmware derived.
>
> Fixes: 47c4846e4319 ("gpu: nova-core: vbios: Add support for FWSEC ucode extraction")
> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
> ---
> drivers/gpu/nova-core/vbios.rs | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> index 2b0dc1a9125d..3bd3ac3a69f2 100644
> --- a/drivers/gpu/nova-core/vbios.rs
> +++ b/drivers/gpu/nova-core/vbios.rs
> @@ -995,14 +995,16 @@ pub(crate) fn header(&self) -> Result<FalconUCodeDesc> {
> // Get the falcon ucode offset that was found in setup_falcon_data.
> let falcon_ucode_offset = self.falcon_ucode_offset;
>
> + let data = self.base.data.get(falcon_ucode_offset..).ok_or(EINVAL)?;
> +
> // Read the first 4 bytes to get the version.
> - let hdr_bytes: [u8; 4] = self.base.data[falcon_ucode_offset..falcon_ucode_offset + 4]
> + let hdr_bytes: [u8; 4] = data
> + .get(..4)
> + .ok_or(EINVAL)?
> .try_into()
> .map_err(|_| EINVAL)?;
> let hdr = u32::from_le_bytes(hdr_bytes);
> let ver = (hdr & 0xff00) >> 8;
> -
> - let data = self.base.data.get(falcon_ucode_offset..).ok_or(EINVAL)?;
> match ver {
> 2 => {
> let v2 = FalconUCodeDescV2::from_bytes_copy_prefix(data)
>

Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>

thanks,

--
Joel Fernandes