Skip to content

Commit

Permalink
drm/amd/display: Ensure array index tg_inst won't be -1
Browse files Browse the repository at this point in the history
[ Upstream commit 687fe32 ]

[WHY & HOW]
tg_inst will be a negative if timing_generator_count equals 0, which
should be checked before used.

This fixes 2 OVERRUN issues reported by Coverity.

Reviewed-by: Harry Wentland <[email protected]>
Acked-by: Tom Chung <[email protected]>
Signed-off-by: Alex Hung <[email protected]>
Tested-by: Daniel Wheeler <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Alex Hung authored and gregkh committed Sep 8, 2024
1 parent 55e07d7 commit a64284b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/display/dc/core/dc_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -3508,7 +3508,7 @@ static bool acquire_otg_master_pipe_for_stream(
if (pool->dpps[pipe_idx])
pipe_ctx->plane_res.mpcc_inst = pool->dpps[pipe_idx]->inst;

if (pipe_idx >= pool->timing_generator_count) {
if (pipe_idx >= pool->timing_generator_count && pool->timing_generator_count != 0) {
int tg_inst = pool->timing_generator_count - 1;

pipe_ctx->stream_res.tg = pool->timing_generators[tg_inst];
Expand Down

0 comments on commit a64284b

Please sign in to comment.