Skip to content

Commit 8cb2f67

Browse files
amd-jaberbacgregkh
authored andcommitted
drm/amd/display: Fix handling of plane refcount
commit 27227a2 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: [email protected] Reviewed-by: Josip Pavic <[email protected]> Signed-off-by: Joshua Aberback <[email protected]> Signed-off-by: Hamza Mahfooz <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 08e5f8e commit 8cb2f67

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • drivers/gpu/drm/amd/display/dc/core

drivers/gpu/drm/amd/display/dc/core/dc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3066,7 +3066,10 @@ static void restore_planes_and_stream_state(
30663066
return;
30673067

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

0 commit comments

Comments
 (0)