Commit 2306439f authored by Alex Hung's avatar Alex Hung Committed by dinglongwei
Browse files

drm/amd/display: Initialize denominators' default to 1

stable inclusion
from stable-v6.11.3
commit 7f8e93b862aba08d540f1e9e03e0ceb4d0cfd5fb
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYRC8
CVE: CVE-2024-49899

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7f8e93b862aba08d540f1e9e03e0ceb4d0cfd5fb



--------------------------------

[ Upstream commit b995c0a6de6c74656a0c39cd57a0626351b13e3c ]

[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: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarJerry Zuo <jerry.zuo@amd.com>
Signed-off-by: default avatarAlex Hung <alex.hung@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Conflicts:
        drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_shared.c
[Context conflicts: no dml2_core_shared.c file in current version,
introduced in higher version]
Signed-off-by: default avatardinglongwei <dinglongwei1@huawei.com>
parent e2e6e833
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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)