mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
gpu: nova-core: vbios: use checked arithmetic for bios image range end
`read_bios_image_at_offset` is called with a length from the VBIOS
header, so we should be more defensive here and use checked arithmetic.
Fixes: 6fda04e7f0 ("gpu: nova-core: vbios: Add base support for VBIOS construction and iteration")
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
Link: https://patch.msgid.link/20260525-fix-vbios-v5-2-e5e455251537@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
fc7c1054b6
commit
7a1d09e477
|
|
@ -238,8 +238,8 @@ fn read_bios_image_at_offset(
|
|||
len: usize,
|
||||
context: &str,
|
||||
) -> Result<BiosImage> {
|
||||
let data_len = self.data.len();
|
||||
if offset + len > data_len {
|
||||
let end = offset.checked_add(len).ok_or(EINVAL)?;
|
||||
if end > self.data.len() {
|
||||
self.read_more_at_offset(offset, len).inspect_err(|e| {
|
||||
dev_err!(
|
||||
self.dev,
|
||||
|
|
@ -250,7 +250,7 @@ fn read_bios_image_at_offset(
|
|||
})?;
|
||||
}
|
||||
|
||||
BiosImage::new(self.dev, &self.data[offset..offset + len]).inspect_err(|err| {
|
||||
BiosImage::new(self.dev, &self.data[offset..end]).inspect_err(|err| {
|
||||
dev_err!(
|
||||
self.dev,
|
||||
"Failed to {} at offset {:#x}: {:?}\n",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user