Skip to content

Commit 6847b3b

Browse files
tiwaialexdeucher
authored andcommitted
drm/amd/display: Add sanity checks for drm_edid_raw()
When EDID is retrieved via drm_edid_raw(), it doesn't guarantee to return proper EDID bytes the caller wants: it may be either NULL (that leads to an Oops) or with too long bytes over the fixed size raw_edid array (that may lead to memory corruption). The latter was reported actually when connected with a bad adapter. Add sanity checks for drm_edid_raw() to address the above corner cases, and return EDID_BAD_INPUT accordingly. Fixes: 48edb2a ("drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid") Link: https://bugzilla.suse.com/show_bug.cgi?id=1236415 Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit 648d3f4) Cc: [email protected]
1 parent 66abb99 commit 6847b3b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,10 @@ enum dc_edid_status dm_helpers_read_local_edid(
10291029
return EDID_NO_RESPONSE;
10301030

10311031
edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw()
1032+
if (!edid ||
1033+
edid->extensions >= sizeof(sink->dc_edid.raw_edid) / EDID_LENGTH)
1034+
return EDID_BAD_INPUT;
1035+
10321036
sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
10331037
memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length);
10341038

0 commit comments

Comments
 (0)