diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-10-20 23:50:21 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-10-20 23:50:21 +0000 |
commit | e73303356258f20e781869d179bc3ad29bfad609 (patch) | |
tree | c6be40cf9a70deb224f1c8bcb4eafddb31af3dd3 /sys | |
parent | 680ad0fd84b796539f67a3856c4cd447b9d0df4b (diff) |
drm/edid: In connector_bad_edid() cap num_of_ext by num_blocks read
From Douglas Anderson
a7b45024f66f9ec769e8dbb1a51ae83cd05929c7 in linux 5.10.y/5.10.75
97794170b696856483f74b47bfb6049780d2d3a0 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/drm_edid.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/dev/pci/drm/drm_edid.c b/sys/dev/pci/drm/drm_edid.c index 65a9f5a61d5..9a232baf9b1 100644 --- a/sys/dev/pci/drm/drm_edid.c +++ b/sys/dev/pci/drm/drm_edid.c @@ -1835,14 +1835,20 @@ static void connector_bad_edid(struct drm_connector *connector, u8 *edid, int num_blocks) { int i; - u8 num_of_ext = edid[0x7e]; + u8 last_block; - if (num_of_ext > num_blocks) - num_of_ext = num_blocks; + /* + * 0x7e in the EDID is the number of extension blocks. The EDID + * is 1 (base block) + num_ext_blocks big. That means we can think + * of 0x7e in the EDID of the _index_ of the last block in the + * combined chunk of memory. + */ + last_block = edid[0x7e]; /* Calculate real checksum for the last edid extension block data */ - connector->real_edid_checksum = - drm_edid_block_checksum(edid + num_of_ext * EDID_LENGTH); + if (last_block < num_blocks) + connector->real_edid_checksum = + drm_edid_block_checksum(edid + last_block * EDID_LENGTH); if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS)) return; |