drm/amd/display: Check link_index before accessing dc->links[]
authorAlex Hung <alex.hung@amd.com>
Tue, 16 Apr 2024 22:30:17 +0000 (16:30 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 May 2024 20:18:17 +0000 (16:18 -0400)
commit8aa2864044b9d13e95fe224f32e808afbf79ecdf
tree5a68f43d5b71a1dc3d76a12de8a336471cc91ad2
parent52cbcf980509e6190740dd1e2a1a437e8fb8101b
drm/amd/display: Check link_index before accessing dc->links[]

[WHY & HOW]
dc->links[] has max size of MAX_LINKS and NULL is return when trying to
access with out-of-bound index.

This fixes 3 OVERRUN and 1 RESOURCE_LEAK issues reported by Coverity.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Tom Chung <chiahsuan.chung@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_link_exports.c