Commit eed0b08a authored by Srinivasan Shanmugam's avatar Srinivasan Shanmugam Committed by Li Huafei
Browse files

drm/amd/display: Add null check for head_pipe in dcn32_acquire_idle_pipe_for_head_pipe_in_layer

mainline inclusion
from mainline-v6.12-rc1
commit ac2140449184a26eac99585b7f69814bd3ba8f2d
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYRAX
CVE: CVE-2024-49918

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac2140449184a26eac99585b7f69814bd3ba8f2d



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

This commit addresses a potential null pointer dereference issue in the
`dcn32_acquire_idle_pipe_for_head_pipe_in_layer` function. The issue
could occur when `head_pipe` is null.

The fix adds a check to ensure `head_pipe` is not null before asserting
it. If `head_pipe` is null, the function returns NULL to prevent a
potential null pointer dereference.

Reported by smatch:
drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn32/dcn32_resource.c:2690 dcn32_acquire_idle_pipe_for_head_pipe_in_layer() error: we previously assumed 'head_pipe' could be null (see line 2681)

Cc: Tom Chung <chiahsuan.chung@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Roman Li <roman.li@amd.com>
Cc: Alex Hung <alex.hung@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Hamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: default avatarTom Chung <chiahsuan.chung@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Conflicts:
	drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
	drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
[ Resolve the conflict caused by renaming files in the commit
8b8eed05a1c6 ('drm/amd/display: Refactor resource into component
directory'). ]
Signed-off-by: default avatarLi Huafei <lihuafei1@huawei.com>
parent 1db462db
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2642,8 +2642,10 @@ static struct pipe_ctx *dcn32_acquire_idle_pipe_for_head_pipe_in_layer(
	struct resource_context *old_ctx = &stream->ctx->dc->current_state->res_ctx;
	int head_index;

	if (!head_pipe)
	if (!head_pipe) {
		ASSERT(0);
		return NULL;
	}

	/*
	 * Modified from dcn20_acquire_idle_pipe_for_layer