mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/3] drm/amd/display: Fix dangling pointers in state reset functions
@ 2026-06-29  9:04 Evgenii Burenchev
  2026-06-29  9:04 ` [PATCH v4 1/3] drm/amd/display: Fix dangling pointer in plane reset function Evgenii Burenchev
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Evgenii Burenchev @ 2026-06-29  9:04 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Evgenii Burenchev, harry.wentland, sunpeng.li, siqueira,
	alexander.deucher, christian.koenig, airlied, simona,
	mario.limonciello, alex.hung, superm1, timur.kristof,
	ivan.lipski, ray.wu, aurabindo.pillai, chen-yu.chen, mripard,
	Dillon.Varone, mwen, chiahsuan.chung, kenneth.feng,
	srinivasan.shanmugam, tzimmermann, Alvin.Lee2, dmitry.baryshkov,
	chaitanya.kumar.borah, ekurzinger, pierre-eric.pelloux-prayer,
	HaoPing.Liu, Tony.Cheng, amd-gfx, dri-devel, linux-kernel,
	lvc-project

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-29 20:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

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®