]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Sep 2024 09:06:40 +0000 (11:06 +0200)
[ Upstream commit 51dfc0a4d609fe700750a62f41447f01b8c9ea50 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c

index 469352e2d6ecffff3dfb36480c0ae0c5f3c9eb8e..436d436b2ea2311c451ba0b4447c44b355abfc02 100644 (file)
@@ -1626,6 +1626,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];
                                                                }