drm/amd/display: Stop amdgpu_dm initialize when stream nums greater than 6
authorHersen Wu <hersenxs.wu@amd.com>
Wed, 24 Apr 2024 20:00:19 +0000 (16:00 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 May 2024 20:18:16 +0000 (16:18 -0400)
[Why]
Coverity reports OVERRUN warning. Should abort amdgpu_dm
initialize.

[How]
Return failure to amdgpu_dm_init.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Tom Chung <chiahsuan.chung@amd.com>
Signed-off-by: Hersen Wu <hersenxs.wu@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index b0e50b3..cce9593 100644 (file)
@@ -4566,7 +4566,10 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
 
        /* There is one primary plane per CRTC */
        primary_planes = dm->dc->caps.max_streams;
-       ASSERT(primary_planes <= AMDGPU_MAX_PLANES);
+       if (primary_planes > AMDGPU_MAX_PLANES) {
+               DRM_ERROR("DM: Plane nums out of 6 planes\n");
+               return -EINVAL;
+       }
 
        /*
         * Initialize primary planes, implicit planes for legacy IOCTLS.