Skip to content

Commit c81c5bd

Browse files
PauloMigAlmeidaalexdeucher
authored andcommitted
drm/radeon: Replace one-element array with flexible-array member
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct _ATOM_FAKE_EDID_PATCH_RECORD and refactor the rest of the code accordingly. It's worth mentioning that doing a build before/after this patch results in no binary output differences. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1]. Link: KSPP#79 Link: KSPP#239 Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [1] Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Paulo Miguel Almeida <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent e053d71 commit c81c5bd

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/gpu/drm/radeon/atombios.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3615,7 +3615,7 @@ typedef struct _ATOM_FAKE_EDID_PATCH_RECORD
36153615
{
36163616
UCHAR ucRecordType;
36173617
UCHAR ucFakeEDIDLength;
3618-
UCHAR ucFakeEDIDString[1]; // This actually has ucFakeEdidLength elements.
3618+
UCHAR ucFakeEDIDString[]; // This actually has ucFakeEdidLength elements.
36193619
} ATOM_FAKE_EDID_PATCH_RECORD;
36203620

36213621
typedef struct _ATOM_PANEL_RESOLUTION_PATCH_RECORD

drivers/gpu/drm/radeon/radeon_atombios.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,8 +1727,11 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
17271727
}
17281728
}
17291729
record += fake_edid_record->ucFakeEDIDLength ?
1730-
fake_edid_record->ucFakeEDIDLength + 2 :
1731-
sizeof(ATOM_FAKE_EDID_PATCH_RECORD);
1730+
struct_size(fake_edid_record,
1731+
ucFakeEDIDString,
1732+
fake_edid_record->ucFakeEDIDLength) :
1733+
/* empty fake edid record must be 3 bytes long */
1734+
sizeof(ATOM_FAKE_EDID_PATCH_RECORD) + 1;
17321735
break;
17331736
case LCD_PANEL_RESOLUTION_RECORD_TYPE:
17341737
panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record;

0 commit comments

Comments
 (0)