Commit 39cb8280 authored by Alex Hung's avatar Alex Hung Committed by Guo Mengqi
Browse files

drm/amd/display: Check null pointers before using dc->clk_mgr

stable inclusion
from stable-v5.10.227
commit 8d54001f8dccd56146973f23f3ab2ba037a21251
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAZVX4
CVE: CVE-2024-49907

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



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

[ Upstream commit 95d9e0803e51d5a24276b7643b244c7477daf463 ]

[WHY & HOW]
dc->clk_mgr is null checked previously in the same function, indicating
it might be null.

Passing "dc" to "dc->hwss.apply_idle_power_optimizations", which
dereferences null "dc->clk_mgr". (The function pointer resolves to
"dcn35_apply_idle_power_optimizations".)

This fixes 1 FORWARD_NULL issue reported by Coverity.

Reviewed-by: default avatarRodrigo Siqueira <rodrigo.siqueira@amd.com>
Signed-off-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarTom Chung <chiahsuan.chung@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>
Signed-off-by: default avatarGuo Mengqi <guomengqi3@huawei.com>
parent d51fb86c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3077,7 +3077,8 @@ void dc_allow_idle_optimizations(struct dc *dc, bool allow)
	if (allow == dc->idle_optimizations_allowed)
		return;

	if (dc->hwss.apply_idle_power_optimizations && dc->hwss.apply_idle_power_optimizations(dc, allow))
	if (dc->hwss.apply_idle_power_optimizations && dc->clk_mgr != NULL &&
	    dc->hwss.apply_idle_power_optimizations(dc, allow))
		dc->idle_optimizations_allowed = allow;
}