drm/amd/display: Skip updating link encoder for unknown eng_id
authorAlex Hung <alex.hung@amd.com>
Mon, 22 Apr 2024 16:34:17 +0000 (10:34 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 May 2024 20:18:17 +0000 (16:18 -0400)
This prevents accessing to negative index of link_encoders array.

This fixes an OVERRUN issue reported by Coverity.

Reviewed-by: Rodrigo Siqueira <rodrigo.siqueira@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/link/link_factory.c

index cf22b8f28ba6c65394a536465143d1c2f81bd2b6..2c3f5d662285128afd3e5f80b8d04ed756334562 100644 (file)
@@ -390,7 +390,7 @@ static void link_destruct(struct dc_link *link)
                 * the dynamic assignment of link encoders to streams. Virtual links
                 * are not assigned encoder resources on creation.
                 */
-               if (link->link_id.id != CONNECTOR_ID_VIRTUAL) {
+               if (link->link_id.id != CONNECTOR_ID_VIRTUAL && link->eng_id != ENGINE_ID_UNKNOWN) {
                        link->dc->res_pool->link_encoders[link->eng_id - ENGINE_ID_DIGA] = NULL;
                        link->dc->res_pool->dig_link_enc_count--;
                }