]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Persist stream refcount through restore
authorJoshua Aberback <joshua.aberback@amd.com>
Thu, 23 Oct 2025 20:43:56 +0000 (16:43 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 4 Nov 2025 16:53:20 +0000 (11:53 -0500)
[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>
drivers/gpu/drm/amd/display/dc/core/dc.c

index b720e007c654098fc49835e20f3db7ca7a0a5851..f519e5893a68a7796b11cc9cde43469005f5c5c9 100644 (file)
@@ -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;
 }
 
 /**