]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amd/display: Initialize denominators' default to 1
authorAlex Hung <alex.hung@amd.com>
Tue, 18 Jun 2024 20:05:08 +0000 (14:05 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 23 Jul 2024 21:07:10 +0000 (17:07 -0400)
[WHAT & HOW]
Variables used as denominators and maybe not assigned to other values,
should not be 0. Change their default to 1 so they are never 0.

This fixes 10 DIVIDE_BY_ZERO issues reported by Coverity.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Jerry Zuo <jerry.zuo@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/dml/dcn20/display_rq_dlg_calc_20.c
drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c
drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_shared.c

index 7c56ad0f881224333f60d265313bcde6f896cfa8..e7019c95ba79ec654532e53dc3e18b9a8ac0ed36 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 dae13f202220e35a295f49ea09eafe014928e3da..d8bfc85e5dcd0f2390bd8dbf38a1c0a6cf7b44e7 100644 (file)
@@ -39,7 +39,7 @@
 
 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 81f0a6f19f87b7c153f7ae4f4c9f1fe3fa988057..679b200319034152a9790e9f1b680d0d3949011d 100644 (file)
@@ -9386,8 +9386,8 @@ static void CalculateVMGroupAndRequestTimes(
        double TimePerVMRequestVBlank[],
        double TimePerVMRequestFlip[])
 {
-       unsigned int num_group_per_lower_vm_stage = 0;
-       unsigned int num_req_per_lower_vm_stage = 0;
+       unsigned int num_group_per_lower_vm_stage = 1;
+       unsigned int num_req_per_lower_vm_stage = 1;
 
 #ifdef __DML_VBA_DEBUG__
        dml2_printf("DML::%s: NumberOfActiveSurfaces = %u\n", __func__, NumberOfActiveSurfaces);