drm/amd/display: Fix pointer dereferenced before checking
authorHaowen Bai <baihaowen@meizu.com>
Thu, 24 Mar 2022 09:27:14 +0000 (17:27 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 1 Apr 2022 03:05:53 +0000 (23:05 -0400)
The pointer edid_buf is dereferencing pointer edid before edid is being
 null checked. Fix this by assigning edid->raw_edid to edid_buf only if
edid is not NULL, otherwise just NULL.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c

index f5f3998..28cf24f 100644 (file)
@@ -90,7 +90,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 {
        struct amdgpu_dm_connector *aconnector = link->priv;
        struct drm_connector *connector = &aconnector->base;
-       struct edid *edid_buf = (struct edid *) edid->raw_edid;
+       struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
        struct cea_sad *sads;
        int sad_count = -1;
        int sadb_count = -1;