Skip to content

Commit 3ac31c9

Browse files
Alex Hungalexdeucher
authored andcommitted
drm/amd/display: Do not return negative stream id for array
[WHY] resource_stream_to_stream_idx returns an array index and it return -1 when not found; however, -1 is not a valid array index number. [HOW] When this happens, call ASSERT(), and return a zero instead. This fixes an OVERRUN and an NEGATIVE_RETURNS issues reported by Coverity. Reviewed-by: Rodrigo Siqueira <[email protected]> Acked-by: Wayne Lin <[email protected]> Signed-off-by: Alex Hung <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent f1fd8a0 commit 3ac31c9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/gpu/drm/amd/display/dc/core/dc_resource.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,13 @@ static int resource_stream_to_stream_idx(struct dc_state *state,
22432243
stream_idx = i;
22442244
break;
22452245
}
2246+
2247+
/* never return negative array index */
2248+
if (stream_idx == -1) {
2249+
ASSERT(0);
2250+
return 0;
2251+
}
2252+
22462253
return stream_idx;
22472254
}
22482255

0 commit comments

Comments
 (0)