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

drm/amd/display: Fix handling of plane refcount



[Why]
The mechanism to backup and restore plane states doesn't maintain
refcount, which can cause issues if the refcount of the plane changes
in between backup and restore operations, such as memory leaks if the
refcount was supposed to go down, or double frees / invalid memory
accesses if the refcount was supposed to go up.

[How]
Cache and re-apply current refcount when restoring plane states.

Cc: stable@vger.kernel.org
Reviewed-by: default avatarJosip Pavic <josip.pavic@amd.com>
Signed-off-by: default avatarJoshua Aberback <joshua.aberback@amd.com>
Signed-off-by: default avatarHamza Mahfooz <hamza.mahfooz@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c33a9320
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3141,7 +3141,10 @@ static void restore_planes_and_stream_state(
		return;

	for (i = 0; i < status->plane_count; i++) {
		/* refcount will always be valid, restore everything else */
		struct kref refcount = status->plane_states[i]->refcount;
		*status->plane_states[i] = scratch->plane_states[i];
		status->plane_states[i]->refcount = refcount;
	}
	*stream = scratch->stream_state;
}