Commit bcafdc61 authored by Ryan Seto's avatar Ryan Seto Committed by Alex Deucher
Browse files

drm/amd/display: Handle dml allocation failure to avoid crash



[Why]
In the case where a dml allocation fails for any reason, the
current state's dml contexts would no longer be valid. Then
subsequent calls dc_state_copy_internal would shallow copy
invalid memory and if the new state was released, a double
free would occur.

[How]
Reset dml pointers in new_state to NULL and avoid invalid
pointer

Reviewed-by: default avatarDillon Varone <dillon.varone@amd.com>
Signed-off-by: default avatarRyan Seto <ryanseto@amd.com>
Signed-off-by: default avatarHamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e77a8005
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -265,6 +265,9 @@ struct dc_state *dc_state_create_copy(struct dc_state *src_state)
	dc_state_copy_internal(new_state, src_state);

#ifdef CONFIG_DRM_AMD_DC_FP
	new_state->bw_ctx.dml2 = NULL;
	new_state->bw_ctx.dml2_dc_power_source = NULL;

	if (src_state->bw_ctx.dml2 &&
			!dml2_create_copy(&new_state->bw_ctx.dml2, src_state->bw_ctx.dml2)) {
		dc_state_release(new_state);