]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amd/display: Validate hw_points_num before using it
authorAlex Hung <alex.hung@amd.com>
Tue, 11 Jul 2023 00:23:58 +0000 (18:23 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 3 Oct 2023 19:42:26 +0000 (15:42 -0400)
[WHAT]
hw_points_num is 0 before ogam LUT is programmed; however, function
"dwb3_program_ogam_pwl" assumes hw_points_num is always greater than 0,
i.e. substracting it by 1 as an array index.

[HOW]
Check hw_points_num is not equal to 0 before using it.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c

index 701c7d8bc038ae7520c1a28ac3321170af69e89b..03a50c32fcfe1fd430d70306b709bb07faa2cad1 100644 (file)
@@ -243,6 +243,9 @@ static bool dwb3_program_ogam_lut(
                return false;
        }
 
+       if (params->hw_points_num == 0)
+               return false;
+
        REG_SET(DWB_OGAM_CONTROL, 0, DWB_OGAM_MODE, 2);
 
        current_mode = dwb3_get_ogam_current(dwbc30);