summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Aberback <joshua.aberback@amd.com>2025-10-23 16:43:56 -0400
committerAlex Deucher <alexander.deucher@amd.com>2025-11-04 11:53:20 -0500
commitb0ba3108e3f8b20d8631ca4475a1a6d171973651 (patch)
tree6afcf213646303de8a44ef3486a00d68966b24f9
parent717b836c27d9a4d5bcaae74fa83f7b3312d45620 (diff)
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: Dillon Varone <dillon.varone@amd.com> Signed-off-by: Joshua Aberback <joshua.aberback@amd.com> Signed-off-by: Ray Wu <ray.wu@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index b720e007c654..f519e5893a68 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -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;
}
/**