Skip to content

Commit bcafdc6

Browse files
Ryan Setoalexdeucher
authored andcommitted
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: Dillon Varone <dillon.varone@amd.com> Signed-off-by: Ryan Seto <ryanseto@amd.com> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent e77a800 commit bcafdc6

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/gpu/drm/amd/display/dc/core/dc_state.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ struct dc_state *dc_state_create_copy(struct dc_state *src_state)
265265
dc_state_copy_internal(new_state, src_state);
266266

267267
#ifdef CONFIG_DRM_AMD_DC_FP
268+
new_state->bw_ctx.dml2 = NULL;
269+
new_state->bw_ctx.dml2_dc_power_source = NULL;
270+
268271
if (src_state->bw_ctx.dml2 &&
269272
!dml2_create_copy(&new_state->bw_ctx.dml2, src_state->bw_ctx.dml2)) {
270273
dc_state_release(new_state);

0 commit comments

Comments
 (0)