drm/amd/display: Initialize get_bytes_per_element's default to 1
authorAlex Hung <alex.hung@amd.com>
Mon, 15 Jul 2024 15:57:01 +0000 (09:57 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Sat, 27 Jul 2024 21:35:44 +0000 (17:35 -0400)
Variables, used as denominators and maybe not assigned to other values,
should not be 0. bytes_per_element_y & bytes_per_element_c are
initialized by get_bytes_per_element() which should never return 0.

This fixes 10 DIVIDE_BY_ZERO issues reported by Coverity.

Signed-off-by: Alex Hung <alex.hung@amd.com>
Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20v2.c
drivers/gpu/drm/amd/display/dc/dml/dcn21/display_rq_dlg_calc_21.c

index 3d95bfa5aca23b25a41c93a6f1cfb4a2dfe524b7..ae52510417280130cf3100da7a1232a1d642c77b 100644 (file)
@@ -78,7 +78,7 @@ static void calculate_ttu_cursor(struct display_mode_lib *mode_lib,
 
 static unsigned int get_bytes_per_element(enum source_format_class source_format, bool is_chroma)
 {
-       unsigned int ret_val = 0;
+       unsigned int ret_val = 1;
 
        if (source_format == dm_444_16) {
                if (!is_chroma)
index 98502a4f0567267f52942e4d3fb4e3186fd285b7..9e1c18b90805d26003277b6f5c1d842f7ac0d75b 100644 (file)
@@ -53,7 +53,7 @@ static void calculate_ttu_cursor(
 
 static unsigned int get_bytes_per_element(enum source_format_class source_format, bool is_chroma)
 {
-       unsigned int ret_val = 0;
+       unsigned int ret_val = 1;
 
        if (source_format == dm_444_16) {
                if (!is_chroma)