mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 14:51:51 -04:00
gpu: nova-core: use checked arithmetic in BinFirmware::data
Use checked_add() when computing the firmware data end offset in the BinFirmware::data() method. The data_offset and data_size fields come from the BinHdr structure parsed from the firmware file header. Reviewed-by: Zhi Wang <zhiw@nvidia.com> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260126202305.2526618-5-joelagnelf@nvidia.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
This commit is contained in:
committed by
Alexandre Courbot
parent
457c70b7dd
commit
35ae4e58a7
@@ -394,8 +394,9 @@ fn new(fw: &'a firmware::Firmware) -> Result<Self> {
|
||||
fn data(&self) -> Option<&[u8]> {
|
||||
let fw_start = usize::from_safe_cast(self.hdr.data_offset);
|
||||
let fw_size = usize::from_safe_cast(self.hdr.data_size);
|
||||
let fw_end = fw_start.checked_add(fw_size)?;
|
||||
|
||||
self.fw.get(fw_start..fw_start + fw_size)
|
||||
self.fw.get(fw_start..fw_end)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user