drm/amd/display: Check num_valid_sets before accessing reader_wm_sets[]
authorAlex Hung <alex.hung@amd.com>
Tue, 16 Apr 2024 22:22:35 +0000 (16:22 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 May 2024 20:18:17 +0000 (16:18 -0400)
commitb38a4815f79b87efb196cd5121579fc51e29a7fb
treee3e5c3d4408743f321bfad51263f2ba44367283f
parent4e70c0f5251c25885c31ee84a31f99a01f7cf50e
drm/amd/display: Check num_valid_sets before accessing reader_wm_sets[]

[WHY & HOW]
num_valid_sets needs to be checked to avoid a negative index when
accessing reader_wm_sets[num_valid_sets - 1].

This fixes an OVERRUN issue 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>
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c