Skip to content

Commit 0f15cbc

Browse files
superm1alexdeucher
authored andcommitted
drm/amd: Sanity check the ACPI EDID
An HP Pavilion Aero Laptop 13-be0xxx/8916 has an ACPI EDID, but using it is causing corruption. It's got illogical values of not specifying a digital interface. Sanity check the ACPI EDID to avoid tripping such problems. Suggested-by: Tobias Jakobi <[email protected]> Reported-and-tested-by: Chris Bainbridge <[email protected]> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3782 Fixes: c6a8370 ("drm/amd/display: Fetch the EDID from _DDC if available for eDP") Reviewed-by: Harry Wentland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 6892751 commit 0f15cbc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,14 +907,14 @@ dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block, size_t len)
907907
struct drm_connector *connector = data;
908908
struct acpi_device *acpidev = ACPI_COMPANION(connector->dev->dev);
909909
unsigned char start = block * EDID_LENGTH;
910-
void *edid;
910+
struct edid *edid;
911911
int r;
912912

913913
if (!acpidev)
914914
return -ENODEV;
915915

916916
/* fetch the entire edid from BIOS */
917-
r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, &edid);
917+
r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, (void *)&edid);
918918
if (r < 0) {
919919
drm_dbg(connector->dev, "Failed to get EDID from ACPI: %d\n", r);
920920
return r;
@@ -924,7 +924,14 @@ dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block, size_t len)
924924
goto cleanup;
925925
}
926926

927-
memcpy(buf, edid + start, len);
927+
/* sanity check */
928+
if (edid->revision < 4 || !(edid->input & DRM_EDID_INPUT_DIGITAL) ||
929+
(edid->input & DRM_EDID_DIGITAL_TYPE_MASK) == DRM_EDID_DIGITAL_TYPE_UNDEF) {
930+
r = -EINVAL;
931+
goto cleanup;
932+
}
933+
934+
memcpy(buf, (void *)edid + start, len);
928935
r = 0;
929936

930937
cleanup:

0 commit comments

Comments
 (0)