From: Timoyoungster <[email protected]>

Instead of manually calculating the EDID block count by reading the
extensions field from the raw edid structure (`edid->extensions + 1`),
utilize the core DRM helper `drm_edid_block_count()`.

This now includes possible HF-EEODB extension blocks, which are not
included in `edid->extensions` and were previously truncated with the
`memmove`.

Signed-off-by: Timo Prömer <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index c6f94eb71..d6d6ea719 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -1160,6 +1160,7 @@ enum dc_edid_status dm_helpers_read_local_edid(
        struct drm_connector *connector = &aconnector->base;
        struct i2c_adapter *ddc;
        int retry = 25;
+       int block_count;
        enum dc_edid_status edid_status = EDID_NO_RESPONSE;
        const struct drm_edid *drm_edid;
        const struct edid *edid;
@@ -1201,11 +1202,15 @@ enum dc_edid_status dm_helpers_read_local_edid(
                        continue;
 
                edid = drm_edid_raw(drm_edid); // FIXME: Get rid of 
drm_edid_raw()
-               if (!edid ||
-                   edid->extensions >= sizeof(sink->dc_edid.raw_edid) / 
EDID_LENGTH)
+               if (!edid)
                        return EDID_BAD_INPUT;
 
-               sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
+               block_count = drm_edid_block_count(drm_edid);
+
+               if (block_count > sizeof(sink->dc_edid.raw_edid) / EDID_LENGTH)
+                       return EDID_BAD_INPUT;
+
+               sink->dc_edid.length = EDID_LENGTH * block_count;
                memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, 
sink->dc_edid.length);
 
                /* We don't need the original edid anymore */
-- 
2.55.0

Reply via email to