]> git.hungrycats.org Git - linux/commitdiff
drm/amd/display: Fix handling of plane refcount
authorJoshua Aberback <joshua.aberback@amd.com>
Mon, 28 Oct 2024 21:12:22 +0000 (17:12 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Dec 2024 09:41:15 +0000 (10:41 +0100)
commit 27227a234c1487cb7a684615f0749c455218833a upstream.

[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: Josip Pavic <josip.pavic@amd.com>
Signed-off-by: Joshua Aberback <joshua.aberback@amd.com>
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/display/dc/core/dc.c

index a88f1b6ea64cfa2a4447a47747e1fd7c652a9c6e..a6911bb2cf0c6c12e1b009ae2e6b92f8057879c0 100644 (file)
@@ -3066,7 +3066,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;
 }