Commit 827c5175 authored by Wayne Lin's avatar Wayne Lin Committed by Cheng Yu
Browse files

drm/amd/display: Check null pointer before try to access it

mainline inclusion
from mainline-v6.12-rc1
commit 66e2d2d9a59f896def82a1c8684368be45cf4c06
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYRAN
CVE: CVE-2024-49906

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



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

[why & how]
Make sure plane_state is not null before calling a function
that dereferences it. Besides, remove redundant codes.

Reviewed-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarWayne Lin <Wayne.Lin@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>
Conflicts:
        drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
        drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
[The conflict is mainly due to e53524cdcc02("drm/amd/display: Refactor
HWSS into component folder") not being merged, and some contextual
differences.]
Signed-off-by: default avatarCheng Yu <serein.chengyu@huawei.com>
parent c63eb3a0
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
@@ -1738,21 +1738,15 @@ static void dcn20_program_pipe(
	    pipe_ctx->stream->update_flags.raw)
		dcn20_update_dchubp_dpp(dc, pipe_ctx, context);

	if (pipe_ctx->update_flags.bits.enable ||
	    (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.hdr_mult))
		hws->funcs.set_hdr_multiplier(pipe_ctx);

	if ((pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.hdr_mult) ||
	    pipe_ctx->update_flags.bits.enable)
	if (pipe_ctx->plane_state && (pipe_ctx->update_flags.bits.enable ||
	    pipe_ctx->plane_state->update_flags.bits.hdr_mult))
		hws->funcs.set_hdr_multiplier(pipe_ctx);

	if ((pipe_ctx->plane_state &&
	     pipe_ctx->plane_state->update_flags.bits.in_transfer_func_change) ||
	    (pipe_ctx->plane_state &&
	     pipe_ctx->plane_state->update_flags.bits.gamma_change) ||
	    (pipe_ctx->plane_state &&
	     pipe_ctx->plane_state->update_flags.bits.lut_3d) ||
	     pipe_ctx->update_flags.bits.enable)
	if (pipe_ctx->plane_state &&
	    (pipe_ctx->plane_state->update_flags.bits.in_transfer_func_change ||
	    pipe_ctx->plane_state->update_flags.bits.gamma_change ||
	    pipe_ctx->plane_state->update_flags.bits.lut_3d ||
	    pipe_ctx->update_flags.bits.enable))
		hws->funcs.set_input_transfer_func(dc, pipe_ctx, pipe_ctx->plane_state);

	/* dcn10_translate_regamma_to_hw_format takes 750us to finish