mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 22:57:21 -04:00
drm/amd/display: Skip accessing array for unknown eng_id
[WHY] ENGINE_ID_UNKNOWN (-1) is not a valid eng_id and not a valid array index. [HOW] Check whether eng_id is unknown to avoid access array with negative array index. This fixes 4 OVERRUN issues reported by Coverity. Reviewed-by: Harry Wentland <harry.wentland@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>
This commit is contained in:
@@ -248,6 +248,8 @@ static struct link_encoder *get_link_enc_used_by_link(
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
struct link_enc_assignment assignment = state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i];
|
||||
if (assignment.eng_id == ENGINE_ID_UNKNOWN)
|
||||
continue;
|
||||
|
||||
if (assignment.valid == true && are_ep_ids_equal(&assignment.ep_id, &ep_id))
|
||||
link_enc = link->dc->res_pool->link_encoders[assignment.eng_id - ENGINE_ID_DIGA];
|
||||
@@ -517,6 +519,8 @@ struct link_encoder *link_enc_cfg_get_link_enc_used_by_link(
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
struct link_enc_assignment assignment = get_assignment(dc, i);
|
||||
if (assignment.eng_id == ENGINE_ID_UNKNOWN)
|
||||
continue;
|
||||
|
||||
if (assignment.valid == true && are_ep_ids_equal(&assignment.ep_id, &ep_id)) {
|
||||
link_enc = link->dc->res_pool->link_encoders[assignment.eng_id - ENGINE_ID_DIGA];
|
||||
@@ -540,7 +544,7 @@ struct link_encoder *link_enc_cfg_get_next_avail_link_enc(struct dc *dc)
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
struct link_enc_assignment assignment = get_assignment(dc, i);
|
||||
|
||||
if (assignment.valid)
|
||||
if (assignment.valid && assignment.eng_id != ENGINE_ID_UNKNOWN)
|
||||
encs_assigned[assignment.eng_id - ENGINE_ID_DIGA] = assignment.eng_id;
|
||||
}
|
||||
|
||||
@@ -602,6 +606,9 @@ struct link_encoder *link_enc_cfg_get_link_enc_used_by_stream_current(
|
||||
struct link_enc_assignment assignment =
|
||||
dc->current_state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i];
|
||||
|
||||
if (assignment.eng_id == ENGINE_ID_UNKNOWN)
|
||||
continue;
|
||||
|
||||
if (assignment.valid == true && are_ep_ids_equal(&assignment.ep_id, &ep_id)) {
|
||||
link_enc = stream->link->dc->res_pool->link_encoders[assignment.eng_id - ENGINE_ID_DIGA];
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user