drm/amd/display: Skip finding free audio for unknown engine_id
authorAlex Hung <alex.hung@amd.com>
Mon, 22 Apr 2024 19:52:27 +0000 (13:52 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 26 Apr 2024 21:22:44 +0000 (17:22 -0400)
[WHY]
ENGINE_ID_UNKNOWN = -1 and can not be used as an array index. Plus, it
also means it is uninitialized and does not need free audio.

[HOW]
Skip and return NULL.

This fixes 2 OVERRUN issues reported by Coverity.

Reviewed-by: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Acked-by: Wayne Lin <wayne.lin@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_resource.c

index 876b0e5eda95f5839d9f4ca10ceb1a06c16becb6..25b5e41648c422828a612986861ad2b3aa6c6788 100644 (file)
@@ -3187,6 +3187,9 @@ static struct audio *find_first_free_audio(
 {
        int i, available_audio_count;
 
+       if (id == ENGINE_ID_UNKNOWN)
+               return NULL;
+
        available_audio_count = pool->audio_count;
 
        for (i = 0; i < available_audio_count; i++) {