All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu/pptable: Fix UBSAN array-index-out-of-bounds
@ 2024-05-23  7:16 Tasos Sahanidis
  2024-05-23 14:52 ` Alex Deucher
  0 siblings, 1 reply; 6+ messages in thread
From: Tasos Sahanidis @ 2024-05-23  7:16 UTC (permalink / raw)
  To: amd-gfx; +Cc: Tasos Sahanidis

Dyanmically sized arrays used [1] instead of []. Replacing the former
with the latter resolves multiple warnings observed on boot with a
BONAIRE card.

Signed-off-by: Tasos Sahanidis <tasos@tasossah.com>
---
 drivers/gpu/drm/amd/include/pptable.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/include/pptable.h b/drivers/gpu/drm/amd/include/pptable.h
index 2e8e6c9875f6..d1dec880d2d6 100644
--- a/drivers/gpu/drm/amd/include/pptable.h
+++ b/drivers/gpu/drm/amd/include/pptable.h
@@ -480,7 +480,7 @@ typedef struct _StateArray{
     //how many states we have 
     UCHAR ucNumEntries;
     
-    ATOM_PPLIB_STATE_V2 states[1];
+    ATOM_PPLIB_STATE_V2 states[];
 }StateArray;
 
 
@@ -514,7 +514,7 @@ typedef struct _ATOM_PPLIB_Clock_Voltage_Dependency_Record
 typedef struct _ATOM_PPLIB_Clock_Voltage_Dependency_Table
 {
     UCHAR ucNumEntries;                                                // Number of entries.
-    ATOM_PPLIB_Clock_Voltage_Dependency_Record entries[1];             // Dynamically allocate entries.
+    ATOM_PPLIB_Clock_Voltage_Dependency_Record entries[];              // Dynamically allocate entries.
 }ATOM_PPLIB_Clock_Voltage_Dependency_Table;
 
 typedef struct _ATOM_PPLIB_Clock_Voltage_Limit_Record
@@ -530,7 +530,7 @@ typedef struct _ATOM_PPLIB_Clock_Voltage_Limit_Record
 typedef struct _ATOM_PPLIB_Clock_Voltage_Limit_Table
 {
     UCHAR ucNumEntries;                                                // Number of entries.
-    ATOM_PPLIB_Clock_Voltage_Limit_Record entries[1];                  // Dynamically allocate entries.
+    ATOM_PPLIB_Clock_Voltage_Limit_Record entries[];                   // Dynamically allocate entries.
 }ATOM_PPLIB_Clock_Voltage_Limit_Table;
 
 union _ATOM_PPLIB_CAC_Leakage_Record
@@ -554,7 +554,7 @@ typedef union _ATOM_PPLIB_CAC_Leakage_Record ATOM_PPLIB_CAC_Leakage_Record;
 typedef struct _ATOM_PPLIB_CAC_Leakage_Table
 {
     UCHAR ucNumEntries;                                                 // Number of entries.
-    ATOM_PPLIB_CAC_Leakage_Record entries[1];                           // Dynamically allocate entries.
+    ATOM_PPLIB_CAC_Leakage_Record entries[];                            // Dynamically allocate entries.
 }ATOM_PPLIB_CAC_Leakage_Table;
 
 typedef struct _ATOM_PPLIB_PhaseSheddingLimits_Record
@@ -569,7 +569,7 @@ typedef struct _ATOM_PPLIB_PhaseSheddingLimits_Record
 typedef struct _ATOM_PPLIB_PhaseSheddingLimits_Table
 {
     UCHAR ucNumEntries;                                                 // Number of entries.
-    ATOM_PPLIB_PhaseSheddingLimits_Record entries[1];                   // Dynamically allocate entries.
+    ATOM_PPLIB_PhaseSheddingLimits_Record entries[];                    // Dynamically allocate entries.
 }ATOM_PPLIB_PhaseSheddingLimits_Table;
 
 typedef struct _VCEClockInfo{
@@ -581,7 +581,7 @@ typedef struct _VCEClockInfo{
 
 typedef struct _VCEClockInfoArray{
     UCHAR ucNumEntries;
-    VCEClockInfo entries[1];
+    VCEClockInfo entries[];
 }VCEClockInfoArray;
 
 typedef struct _ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record
@@ -593,7 +593,7 @@ typedef struct _ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record
 typedef struct _ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table
 {
     UCHAR numEntries;
-    ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record entries[1];
+    ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record entries[];
 }ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table;
 
 typedef struct _ATOM_PPLIB_VCE_State_Record
@@ -605,7 +605,7 @@ typedef struct _ATOM_PPLIB_VCE_State_Record
 typedef struct _ATOM_PPLIB_VCE_State_Table
 {
     UCHAR numEntries;
-    ATOM_PPLIB_VCE_State_Record entries[1];
+    ATOM_PPLIB_VCE_State_Record entries[];
 }ATOM_PPLIB_VCE_State_Table;
 
 
@@ -627,7 +627,7 @@ typedef struct _UVDClockInfo{
 
 typedef struct _UVDClockInfoArray{
     UCHAR ucNumEntries;
-    UVDClockInfo entries[1];
+    UVDClockInfo entries[];
 }UVDClockInfoArray;
 
 typedef struct _ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record
@@ -639,7 +639,7 @@ typedef struct _ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record
 typedef struct _ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table
 {
     UCHAR numEntries;
-    ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record entries[1];
+    ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record entries[];
 }ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table;
 
 typedef struct _ATOM_PPLIB_UVD_Table
@@ -676,7 +676,7 @@ typedef struct _ATOM_PPLIB_ACPClk_Voltage_Limit_Record
 
 typedef struct _ATOM_PPLIB_ACPClk_Voltage_Limit_Table{
     UCHAR numEntries;
-    ATOM_PPLIB_ACPClk_Voltage_Limit_Record entries[1];
+    ATOM_PPLIB_ACPClk_Voltage_Limit_Record entries[];
 }ATOM_PPLIB_ACPClk_Voltage_Limit_Table;
 
 typedef struct _ATOM_PPLIB_ACP_Table
@@ -745,7 +745,7 @@ typedef struct ATOM_PPLIB_VQ_Budgeting_Record{
 typedef struct ATOM_PPLIB_VQ_Budgeting_Table {
     UCHAR revid;
     UCHAR numEntries;
-    ATOM_PPLIB_VQ_Budgeting_Record         entries[1];
+    ATOM_PPLIB_VQ_Budgeting_Record         entries[];
 } ATOM_PPLIB_VQ_Budgeting_Table;
 
 #pragma pack()
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-30 15:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23  7:16 [PATCH] drm/amdgpu/pptable: Fix UBSAN array-index-out-of-bounds Tasos Sahanidis
2024-05-23 14:52 ` Alex Deucher
2024-05-27  9:42   ` Tasos Sahanidis
2024-05-27 14:47     ` Alex Deucher
2024-05-30 10:31       ` Tasos Sahanidis
2024-05-30 15:24         ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.