From: Evgenii Burenchev <evg28bur@yandex.ru>
To: stable@vger.kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Evgenii Burenchev <evg28bur@yandex.ru>,
harry.wentland@amd.com, sunpeng.li@amd.com, siqueira@igalia.com,
alexander.deucher@amd.com, christian.koenig@amd.com,
airlied@gmail.com, simona@ffwll.ch, mario.limonciello@amd.com,
alex.hung@amd.com, superm1@kernel.org, timur.kristof@gmail.com,
ivan.lipski@amd.com, ray.wu@amd.com, aurabindo.pillai@amd.com,
chen-yu.chen@amd.com, mripard@kernel.org, Dillon.Varone@amd.com,
mwen@igalia.com, chiahsuan.chung@amd.com, kenneth.feng@amd.com,
srinivasan.shanmugam@amd.com, tzimmermann@suse.de,
Alvin.Lee2@amd.com, dmitry.baryshkov@oss.qualcomm.com,
chaitanya.kumar.borah@intel.com, ekurzinger@gmail.com,
pierre-eric.pelloux-prayer@amd.com, HaoPing.Liu@amd.com,
Tony.Cheng@amd.com, amd-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: [PATCH v4 1/3] drm/amd/display: Fix dangling pointer in plane reset function
Date: Mon, 29 Jun 2026 12:04:29 +0300 [thread overview]
Message-ID: <20260629090435.9729-3-evg28bur@yandex.ru> (raw)
In-Reply-To: <20260629090435.9729-2-evg28bur@yandex.ru>
amdgpu_dm_plane_drm_plane_reset() frees the old state before allocating
a new one. If kzalloc_obj() 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: 5d945cbcd4b1 ("drm/amd/display: Create a file dedicated to planes")
Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
index c7f8e08feaf4..cfd76c54f652 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
@@ -1488,17 +1488,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;
-
- if (plane->state)
- plane->funcs->atomic_destroy_state(plane, plane->state);
+ struct dm_plane_state *amdgpu_state;
amdgpu_state = kzalloc_obj(*amdgpu_state);
- WARN_ON(amdgpu_state == NULL);
-
if (!amdgpu_state)
return;
+ if (plane->state)
+ plane->funcs->atomic_destroy_state(plane, plane->state);
+
__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;
--
2.43.0
next prev parent reply other threads:[~2026-06-29 9:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 9:04 [PATCH v4 0/3] drm/amd/display: Fix dangling pointers in state reset functions Evgenii Burenchev
2026-06-29 9:04 ` Evgenii Burenchev [this message]
2026-06-29 9:04 ` [PATCH v4 2/3] drm/amd/display: Fix dangling pointer in CRTC reset function Evgenii Burenchev
2026-06-29 9:04 ` [PATCH v4 3/3] drm/amd/display: Fix dangling pointer in connector " Evgenii Burenchev
2026-06-29 20:52 ` [PATCH v4 0/3] drm/amd/display: Fix dangling pointers in state reset functions Mario Limonciello
[not found] <20260629092538.4D19B1F000E9@smtp.kernel.org>
2026-06-29 10:32 ` [PATCH v4 1/3] drm/amd/display: Fix dangling pointer in plane reset function Evgenii Burenchev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260629090435.9729-3-evg28bur@yandex.ru \
--to=evg28bur@yandex.ru \
--cc=Alvin.Lee2@amd.com \
--cc=Dillon.Varone@amd.com \
--cc=HaoPing.Liu@amd.com \
--cc=Tony.Cheng@amd.com \
--cc=airlied@gmail.com \
--cc=alex.hung@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=aurabindo.pillai@amd.com \
--cc=chaitanya.kumar.borah@intel.com \
--cc=chen-yu.chen@amd.com \
--cc=chiahsuan.chung@amd.com \
--cc=christian.koenig@amd.com \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ekurzinger@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=harry.wentland@amd.com \
--cc=ivan.lipski@amd.com \
--cc=kenneth.feng@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mario.limonciello@amd.com \
--cc=mripard@kernel.org \
--cc=mwen@igalia.com \
--cc=pierre-eric.pelloux-prayer@amd.com \
--cc=ray.wu@amd.com \
--cc=simona@ffwll.ch \
--cc=siqueira@igalia.com \
--cc=srinivasan.shanmugam@amd.com \
--cc=stable@vger.kernel.org \
--cc=sunpeng.li@amd.com \
--cc=superm1@kernel.org \
--cc=timur.kristof@gmail.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®