提交 0078e9f9 编写于 作者: J Jani Nikula 提交者: Zheng Zengkai

drm/edid: fix invalid EDID extension block filtering

stable inclusion
from stable-v5.10.121
commit 9072d627857d4bb4008d85858fdc5c8f0598cadd
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9072d627857d4bb4008d85858fdc5c8f0598cadd

--------------------------------

[ Upstream commit 3aefc722 ]

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: 14544d09 ("drm/edid: Only print the bad edid when aborting")
Reported-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: NJani Nikula <jani.nikula@intel.com>
Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220330170426.349248-1-jani.nikula@intel.comSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 62a25a79
...@@ -1995,9 +1995,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, ...@@ -1995,9 +1995,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
connector_bad_edid(connector, edid, edid[0x7e] + 1); 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, new = kmalloc_array(valid_extensions + 1, EDID_LENGTH,
GFP_KERNEL); GFP_KERNEL);
if (!new) if (!new)
...@@ -2014,6 +2011,9 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, ...@@ -2014,6 +2011,9 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
base += EDID_LENGTH; base += EDID_LENGTH;
} }
new[EDID_LENGTH - 1] += new[0x7e] - valid_extensions;
new[0x7e] = valid_extensions;
kfree(edid); kfree(edid);
edid = new; edid = new;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册