]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/radeon: Replace one-element array with flexible-array member
authorPaulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
Sat, 29 Oct 2022 03:32:05 +0000 (16:32 +1300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:07:46 +0000 (15:07 +0200)
[ Upstream commit c81c5bd5cf2f428867e0bcfcccd4e4d2f8c68f51 ]

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: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/239
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Stable-dep-of: 17c6baff3d5f ("drm/radeon: properly handle vbios fake edid sizing")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/radeon/atombios.h
drivers/gpu/drm/radeon/radeon_atombios.c

index 4b86e8b450090664db17009d005f106902259f2a..e3f4964647641bd0e7294be379967077229eed0f 100644 (file)
@@ -3615,7 +3615,7 @@ typedef struct _ATOM_FAKE_EDID_PATCH_RECORD
 {
   UCHAR ucRecordType;
   UCHAR ucFakeEDIDLength;
-  UCHAR ucFakeEDIDString[1];    // This actually has ucFakeEdidLength elements.
+  UCHAR ucFakeEDIDString[];    // This actually has ucFakeEdidLength elements.
 } ATOM_FAKE_EDID_PATCH_RECORD;
 
 typedef struct  _ATOM_PANEL_RESOLUTION_PATCH_RECORD
index aca6e5cfae53dccc409cb0c80a61a1a5bdd83c2d..60197257bca6e83f92d81131721a7d80c3261063 100644 (file)
@@ -1735,8 +1735,11 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
                                                }
                                        }
                                        record += fake_edid_record->ucFakeEDIDLength ?
-                                               fake_edid_record->ucFakeEDIDLength + 2 :
-                                               sizeof(ATOM_FAKE_EDID_PATCH_RECORD);
+                                                 struct_size(fake_edid_record,
+                                                             ucFakeEDIDString,
+                                                             fake_edid_record->ucFakeEDIDLength) :
+                                                 /* empty fake edid record must be 3 bytes long */
+                                                 sizeof(ATOM_FAKE_EDID_PATCH_RECORD) + 1;
                                        break;
                                case LCD_PANEL_RESOLUTION_RECORD_TYPE:
                                        panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record;