drm/amdgpu: fix mc_data out-of-bounds read warning
authorjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 09:24:57 +0000 (09:24 +0000)
committerjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 09:24:57 +0000 (09:24 +0000)
From Tim Huang
d0a43bf367ed640e527e8ef3d53aac1e71f80114 in linux-6.6.y/6.6.50
51dfc0a4d609fe700750a62f41447f01b8c9ea50 in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_atombios.c

index 87bfccd..335dc81 100644 (file)
@@ -1476,6 +1476,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];
                                                                }