Skip to content

Commit 13080d0

Browse files
Hersen Wugregkh
authored andcommitted
drm/amd/display: Stop amdgpu_dm initialize when link nums greater than max_links
commit cf8b16857db702ceb8d52f9219a4613363e2b1cf upstream. [Why] Coverity report OVERRUN warning. There are only max_links elements within dc->links. link count could up to AMDGPU_DM_MAX_DISPLAY_INDEX 31. [How] Make sure link count less than max_links. Reviewed-by: Harry Wentland <[email protected]> Acked-by: Tom Chung <[email protected]> Signed-off-by: Hersen Wu <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]> [Minor conflict resolved due to code context change. And the macro MAX_LINKS is introduced by Commit 60df5628144b ("drm/amd/display: handle invalid connector indices") after 6.10. So here we still use the original array length MAX_PIPES * 2] Signed-off-by: Jianqi Ren <[email protected]> Signed-off-by: He Zhe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 615c8f7 commit 13080d0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4499,17 +4499,17 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
44994499
}
45004500
}
45014501

4502+
if (link_cnt > (MAX_PIPES * 2)) {
4503+
DRM_ERROR(
4504+
"KMS: Cannot support more than %d display indexes\n",
4505+
MAX_PIPES * 2);
4506+
goto fail;
4507+
}
4508+
45024509
/* loops over all connectors on the board */
45034510
for (i = 0; i < link_cnt; i++) {
45044511
struct dc_link *link = NULL;
45054512

4506-
if (i > AMDGPU_DM_MAX_DISPLAY_INDEX) {
4507-
DRM_ERROR(
4508-
"KMS: Cannot support more than %d display indexes\n",
4509-
AMDGPU_DM_MAX_DISPLAY_INDEX);
4510-
continue;
4511-
}
4512-
45134513
aconnector = kzalloc(sizeof(*aconnector), GFP_KERNEL);
45144514
if (!aconnector)
45154515
goto fail;

0 commit comments

Comments
 (0)