mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 0/3] drm/amd/display: Fix dangling pointers in state reset functions
Date: Mon, 29 Jun 2026 12:04:28 +0300	[thread overview]
Message-ID: <20260629090435.9729-2-evg28bur@yandex.ru> (raw)

This series fixes a dangling pointer issue in three reset functions:
- amdgpu_dm_plane_drm_plane_reset()
- amdgpu_dm_crtc_reset_state()
- amdgpu_dm_connector_funcs_reset()

Each function 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.

The fix is to allocate the new state first. On allocation failure,
the old state remains untouched and the function safely returns.

For the connector function, additionally restore the explicit
kfree(old_state) which was lost during refactoring.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
---
Evgenii Burenchev (3):
  drm/amd/display: Fix dangling pointer in plane reset function
  drm/amd/display: Fix dangling pointer in CRTC reset function
  drm/amd/display: Fix dangling pointer in connector reset function

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 39 ++++++++++---------
 .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c    |  8 ++--
 .../amd/display/amdgpu_dm/amdgpu_dm_plane.c   | 10 ++---
 3 files changed, 28 insertions(+), 29 deletions(-)
---
Changes in v4:
- Split into three separate patches as requested (reviewer Fedor Pchelkin)
- Remove WARN_ON on memory allocation failure (reviewer Fedor Pchelkin)
- Remove redundant comments (reviewer Fedor Pchelkin)
- Fix empty line in local variable declaration block (reviewer Fedor Pchelkin)

Changes in v3:
- Restore explicit kfree(old_state) in amdgpu_dm_connector_funcs_reset()
  to prevent memory leak (reviewer Mario Limonciello)

Changes in v2:
- Also fix amdgpu_dm_crtc_reset_state() and amdgpu_dm_connector_funcs_reset()
-- 
2.43.0


             reply	other threads:[~2026-06-29  9:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  9:04 Evgenii Burenchev [this message]
2026-06-29  9:04 ` [PATCH v4 1/3] drm/amd/display: Fix dangling pointer in plane reset function Evgenii Burenchev
2026-06-29  9:04 ` [PATCH v4 2/3] drm/amd/display: Fix dangling pointer in CRTC " 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

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-2-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®