]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/edid: fix invalid EDID extension block filtering
authorJani Nikula <jani.nikula@intel.com>
Wed, 30 Mar 2022 17:04:26 +0000 (20:04 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 14:59:19 +0000 (16:59 +0200)
[ Upstream commit 3aefc722ff52076407203b6af9713de567993adf ]

The invalid EDID block filtering uses the number of valid EDID
extensions instead of all EDID extensions for looping the extensions in
the copy. This is fine, by coincidence, if all the invalid blocks are at
the end of the EDID. However, it's completely broken if there are
invalid extensions in the middle; the invalid blocks are included and
valid blocks are excluded.

Fix it by modifying the base block after, not before, the copy.

Fixes: 14544d0937bf ("drm/edid: Only print the bad edid when aborting")
Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220330170426.349248-1-jani.nikula@intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/drm_edid.c

index ef26095719c5e6313eecad9aee525fa245803f00..28ea3d260bea15fb87ccd9117e6d7a3a549cff22 100644 (file)
@@ -1709,9 +1709,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
 
                connector_bad_edid(connector, edid, edid[0x7e] + 1);
 
-               edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions;
-               edid[0x7e] = valid_extensions;
-
                new = kmalloc_array(valid_extensions + 1, EDID_LENGTH,
                                    GFP_KERNEL);
                if (!new)
@@ -1728,6 +1725,9 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
                        base += EDID_LENGTH;
                }
 
+               new[EDID_LENGTH - 1] += new[0x7e] - valid_extensions;
+               new[0x7e] = valid_extensions;
+
                kfree(edid);
                edid = new;
        }