drm/amd/pm: fix the Out-of-bounds read warning
authorjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 08:39:21 +0000 (08:39 +0000)
committerjsg <jsg@openbsd.org>
Mon, 9 Sep 2024 08:39:21 +0000 (08:39 +0000)
From Jesse Zhang
f1e261ced9bcad772a45a2fcdf413c3490e87299 in linux-6.6.y/6.6.50
12c6967428a099bbba9dfd247bb4322a984fcc0b in mainline linux

sys/dev/pci/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c

index f503e61..cc3b62f 100644 (file)
@@ -73,8 +73,9 @@ static int atomctrl_retrieve_ac_timing(
                                        j++;
                                } else if ((table->mc_reg_address[i].uc_pre_reg_data &
                                                        LOW_NIBBLE_MASK) == DATA_EQU_PREV) {
-                                       table->mc_reg_table_entry[num_ranges].mc_data[i] =
-                                               table->mc_reg_table_entry[num_ranges].mc_data[i-1];
+                                       if (i)
+                                               table->mc_reg_table_entry[num_ranges].mc_data[i] =
+                                                       table->mc_reg_table_entry[num_ranges].mc_data[i-1];
                                }
                        }
                        num_ranges++;