]> git.hungrycats.org Git - linux/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Oct 2024 10:00:35 +0000 (12:00 +0200)
[ Upstream commit 4067f4fa0423a89fb19a30b57231b384d77d2610 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
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 0fc9f3e3ffaefd2c3d56abec6734e701fab997c6..f603486af6e306a778f62afbece867b82242b473 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 618f4b682ab1b1c090a36867b4aabf764af518c0..9f28e4d3c664c710904bbfa5c61a9a895c088ede 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)