Commit b0ba3108 authored by Joshua Aberback's avatar Joshua Aberback Committed by Alex Deucher
Browse files

drm/amd/display: Persist stream refcount through restore



[Why & How]
Overwriting the refcount on stream restore can lead to double-free errors
or memory leaks if an unbalanced number of retains and releases occurs
between a backup and restore.

Reviewed-by: default avatarDillon Varone <dillon.varone@amd.com>
Signed-off-by: default avatarJoshua Aberback <joshua.aberback@amd.com>
Signed-off-by: default avatarRay Wu <ray.wu@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 717b836c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3389,7 +3389,11 @@ static void restore_planes_and_stream_state(
	for (i = 0; i < status->plane_count; i++) {
		dc_plane_copy_config(status->plane_states[i], &scratch->plane_states[i]);
	}

	// refcount is persistent
	struct kref temp_refcount = stream->refcount;
	*stream = scratch->stream_state;
	stream->refcount = temp_refcount;
}

/**