Commit 3ac31c9a authored by Alex Hung's avatar Alex Hung Committed by Alex Deucher

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: default avatarRodrigo Siqueira <rodrigo.siqueira@amd.com>
Acked-by: default avatarWayne Lin <wayne.lin@amd.com>
Signed-off-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent f1fd8a0a
...@@ -2243,6 +2243,13 @@ static int resource_stream_to_stream_idx(struct dc_state *state, ...@@ -2243,6 +2243,13 @@ static int resource_stream_to_stream_idx(struct dc_state *state,
stream_idx = i; stream_idx = i;
break; break;
} }
/* never return negative array index */
if (stream_idx == -1) {
ASSERT(0);
return 0;
}
return stream_idx; return stream_idx;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment