[bug report] drm/amd/display: Handle HDR use cases.

Dan Carpenter dan.carpenter at oracle.com
Wed Mar 14 08:53:57 UTC 2018


Hello Vitaly Prosyak,

The patch 44c6f2e59ee8: "drm/amd/display: Handle HDR use cases." from
Feb 13, 2018, leads to the following static checker warning:

	drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_cm_common.c:543 cm_helper_translate_curve_to_degamma_hw_format()
	warn: potential off by one (named limit 'MAX_REGIONS_NUMBER') 'seg_distr[k]'

drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_cm_common.c
   530          lut_params->hw_points_num = hw_points;
   531  
   532          i = 1;
   533          for (k = 0; k < MAX_REGIONS_NUMBER && i < MAX_REGIONS_NUMBER; k++) {
                            ^^^^^^^^^^^^^^^^^^^^^^
Imagine we hit this limit and k == MAX_REGIONS_NUMBER,

   534                  if (seg_distr[k] != -1) {
   535                          lut_params->arr_curve_points[k].segments_num =
   536                                          seg_distr[k];
   537                          lut_params->arr_curve_points[i].offset =
   538                                          lut_params->arr_curve_points[k].offset + (1 << seg_distr[k]);
   539                  }
   540                  i++;
   541          }
   542  
   543          if (seg_distr[k] != -1)
                    ^^^^^^^^^^^^^^^^^^
then this would be a problem.

   544                  lut_params->arr_curve_points[k].segments_num = seg_distr[k];
   545  

regards,
dan carpenter


More information about the amd-gfx mailing list