]> Gentwo Git Trees - linux/.git/commitdiff
gpu: nova-core: gsp: do not unwrap() SGEntry
authorDanilo Krummrich <dakr@kernel.org>
Fri, 26 Sep 2025 13:05:53 +0000 (15:05 +0200)
committerAlexandre Courbot <acourbot@nvidia.com>
Wed, 15 Oct 2025 23:04:46 +0000 (08:04 +0900)
Don't use unwrap() to extract an Option<SGEntry>, instead handle the
error condition gracefully.

Fixes: a841614e607c ("gpu: nova-core: firmware: process and prepare the GSP firmware")
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Message-ID: <20250926130623.61316-2-dakr@kernel.org>

drivers/gpu/nova-core/firmware/gsp.rs

index ca785860e1c82ab5187e1600cea79dc1aad0598a..6b0761460a57d33330307420a483df204c9c0f10 100644 (file)
@@ -202,9 +202,10 @@ pub(crate) fn new<'a, 'b>(
                 let mut level0_data = kvec![0u8; GSP_PAGE_SIZE]?;
 
                 // Fill level 1 page entry.
-                let level1_entry = level1.iter().next().unwrap().dma_address();
-                let dst = &mut level0_data[..size_of_val(&level1_entry)];
-                dst.copy_from_slice(&level1_entry.to_le_bytes());
+                let level1_entry = level1.iter().next().ok_or(EINVAL)?;
+                let level1_entry_addr = level1_entry.dma_address();
+                let dst = &mut level0_data[..size_of_val(&level1_entry_addr)];
+                dst.copy_from_slice(&level1_entry_addr.to_le_bytes());
 
                 // Turn the level0 page table into a [`DmaObject`].
                 DmaObject::from_data(dev, &level0_data)?