summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Huang <Tim.Huang@amd.com>2024-05-06 16:30:01 +0800
committerAlex Deucher <alexander.deucher@amd.com>2024-05-08 15:17:07 -0400
commit51dfc0a4d609fe700750a62f41447f01b8c9ea50 (patch)
treebdc11b0b02e18b61fd0991cd36192eb4c4499fa2
parent8944acd0f9db33e17f387fdc75d33bb473d7936f (diff)
downloadlinux-51dfc0a4d609fe700750a62f41447f01b8c9ea50.tar.gz
linux-51dfc0a4d609fe700750a62f41447f01b8c9ea50.tar.bz2
linux-51dfc0a4d609fe700750a62f41447f01b8c9ea50.zip
drm/amdgpu: fix mc_data out-of-bounds read warning
Clear warning that read mc_data[i-1] may out-of-bounds. Signed-off-by: Tim Huang <Tim.Huang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 52b12c1718eb..7dc102f0bc1d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -1484,6 +1484,8 @@ int amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev,
(u32)le32_to_cpu(*((u32 *)reg_data + j));
j++;
} else if ((reg_table->mc_reg_address[i].pre_reg_data & LOW_NIBBLE_MASK) == DATA_EQU_PREV) {
+ if (i == 0)
+ continue;
reg_table->mc_reg_table_entry[num_ranges].mc_data[i] =
reg_table->mc_reg_table_entry[num_ranges].mc_data[i - 1];
}