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>
Thu, 9 Jun 2022 08:22:44 +0000 (10:22 +0200)
commit96db9afa4958bbaee77995eb0c84e08cdcce74ae
treefe280d0abbc4a584996dacbb93d11c75b8ffd505
parent996409ee9716f1bfc8973930d1a3370804e5a855
drm/edid: fix invalid EDID extension block filtering

[ 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