]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Check index for aux_rd_interval before using
authorAlex Hung <alex.hung@amd.com>
Fri, 19 Apr 2024 00:22:43 +0000 (18:22 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 May 2024 20:18:16 +0000 (16:18 -0400)
aux_rd_interval has size of 7 and should be checked.

This fixes 3 OVERRUN and 1 INTEGER_OVERFLOW issues reported by Coverity.

Reviewed-by: Rodrigo Siqueira <rodrigo.siqueira@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/link/protocols/link_dp_training.c

index 1818970b8eaf7a3ec4aade857841fc6f7af4b33b..b8e704dbe9567ad24cd8d1b3fe21d9967d6553d3 100644 (file)
@@ -914,10 +914,10 @@ static enum dc_status configure_lttpr_mode_non_transparent(
                        /* Driver does not need to train the first hop. Skip DPCD read and clear
                         * AUX_RD_INTERVAL for DPTX-to-DPIA hop.
                         */
-                       if (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA)
+                       if (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA && repeater_cnt > 0 && repeater_cnt < MAX_REPEATER_CNT)
                                link->dpcd_caps.lttpr_caps.aux_rd_interval[--repeater_cnt] = 0;
 
-                       for (repeater_id = repeater_cnt; repeater_id > 0; repeater_id--) {
+                       for (repeater_id = repeater_cnt; repeater_id > 0 && repeater_id < MAX_REPEATER_CNT; repeater_id--) {
                                aux_interval_address = DP_TRAINING_AUX_RD_INTERVAL_PHY_REPEATER1 +
                                                ((DP_REPEATER_CONFIGURATION_AND_STATUS_SIZE) * (repeater_id - 1));
                                core_link_read_dpcd(