mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
drm/amd/display: Fix dangling pointer in plane reset function
amdgpu_dm_plane_drm_plane_reset() frees the old state before allocating
a new one. If kzalloc() fails, the function returns without updating
the state pointer, leaving a dangling pointer to already freed memory.
Fix this by allocating the new state first. On allocation failure, the
old state remains untouched and the function safely returns.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 5d945cbcd4 ("drm/amd/display: Create a file dedicated to planes")
Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Link: https://patch.msgid.link/20260629090435.9729-3-evg28bur@yandex.ru
[adjust for movement around current amd-staging-drm-next]
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
27213b776a
commit
98cad4bd14
|
|
@ -1517,17 +1517,15 @@ static const struct drm_plane_helper_funcs dm_primary_plane_helper_funcs = {
|
|||
|
||||
static void amdgpu_dm_plane_drm_plane_reset(struct drm_plane *plane)
|
||||
{
|
||||
struct dm_plane_state *amdgpu_state = NULL;
|
||||
struct dm_plane_state *amdgpu_state;
|
||||
|
||||
amdgpu_state = kzalloc_obj(*amdgpu_state);
|
||||
if (!amdgpu_state)
|
||||
return;
|
||||
|
||||
if (plane->state)
|
||||
plane->funcs->atomic_destroy_state(plane, plane->state);
|
||||
|
||||
amdgpu_state = kzalloc_obj(*amdgpu_state);
|
||||
WARN_ON(amdgpu_state == NULL);
|
||||
|
||||
if (!amdgpu_state)
|
||||
return;
|
||||
|
||||
__drm_atomic_helper_plane_reset(plane, &amdgpu_state->base);
|
||||
amdgpu_state->degamma_tf = AMDGPU_TRANSFER_FUNCTION_DEFAULT;
|
||||
amdgpu_state->hdr_mult = AMDGPU_HDR_MULT_DEFAULT;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user