]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: fix mc_data out-of-bounds read warning
authorTim Huang <Tim.Huang@amd.com>
Mon, 6 May 2024 08:30:01 +0000 (16:30 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 8 May 2024 19:17:07 +0000 (15:17 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c

index 52b12c1718eb0ecd38d5563306c959ae675f3438..7dc102f0bc1d3cbf47e86fd1e8fd791101e6955b 100644 (file)
@@ -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];
                                                                }