From 3a811351bffbbbceeef3d0563063f8a98ad0df49 Mon Sep 17 00:00:00 2001 From: zaiovo Date: Wed, 10 May 2023 02:25:32 +0000 Subject: [PATCH] Use the edid without determining whether it is a null pointer drivers inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I71RE6 CVE: NA Reference: N/A ---------------------------------------------------------------- 1.There is no null pointer check before accessing the variable edid. 2.The if check in the original code accesses edid after accessing edid. After keeping the declaration of the edid_buf variable,. 3. I access the edid variable and assign the value to edid_buf under the condition that the if check determines that edid is not a null pointer. Signed-off-by: zaiovo --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 8403b6a9a77b..d9b6bfcaba64 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 @@ -55,7 +55,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps( const struct dc_edid *edid, struct dc_edid_caps *edid_caps) { - struct edid *edid_buf = (struct edid *) edid->raw_edid; + struct edid *edid_buf; struct cea_sad *sads; int sad_count = -1; int sadb_count = -1; @@ -67,6 +67,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps( if (!edid_caps || !edid) return EDID_BAD_INPUT; + else + edid_buf = (struct edid *) edid->raw_edid; if (!drm_edid_is_valid(edid_buf)) result = EDID_BAD_CHECKSUM; -- Gitee