AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] fix TTM device_list use-after-free on failed probe
@ 2026-11-18 19:02 Mario Limonciello
  2026-11-18 19:02 ` [PATCH v2 1/3] drm/amdgpu: unwind TTM on amdgpu_ttm_init() failure Mario Limonciello
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mario Limonciello @ 2026-11-18 19:02 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Mario Limonciello, amd-gfx

When amdgpu probe fails after ttm_device_init() has succeeded, the freed
amdgpu_device stays linked on ttm_glob.device_list. The next
ttm_device_init() or ttm_global_swapout() then touches freed memory
(list_add corruption on the following bind).

Failure points are any error return in amdgpu_ttm_init() after
ttm_device_init(), and gmc_v*_sw_init() failing after amdgpu_bo_init().
In the latter case GMC's status.sw stays false, so amdgpu_device_ip_fini()
skips its sw_fini, which is the only path to amdgpu_bo_fini() ->
amdgpu_ttm_fini() -> ttm_device_fini(). The leaked MMIO_REMAP BO also
shows up as "Memory manager not clean" on the next bind.

Patch 1 unwinds amdgpu_ttm_init() through amdgpu_ttm_fini() and makes
that function safe on a partially initialized device.
Patch 2 unwinds amdgpu_bo_init() in the GMC sw_init paths (v6-v12),
including freeing the pinned GART table and pdb0 BOs first.
Patch 3 releases the WC memtype and MTRR when amdgpu_bo_init() fails
after reserving them.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
Changes in v2:
- Patch 2: free the pinned GART table BO (and pdb0_bo on v9/v12) before
  amdgpu_bo_fini() on the error paths, as sw_fini does; use the RAM
  variant on v9 without VRAM (reported by Sashiko)
- Link to v1: https://patch.msgid.link/20261113-superm1-amdgpu-memory-leak-v1-0-4a495cfc2c92@amd.com

To: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org

---
Mario Limonciello (3):
      drm/amdgpu: unwind TTM on amdgpu_ttm_init() failure
      drm/amdgpu: unwind bo_init on GMC sw_init failure
      drm/amdgpu: release WC memtype and MTRR when amdgpu_bo_init() fails

 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 20 +++++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 43 ++++++++++++++++++------------
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c     | 11 ++++++--
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c     | 11 ++++++--
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c     | 12 +++++++--
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c      |  7 ++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c      | 15 ++++++++---
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c      | 15 ++++++++---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c      | 17 ++++++++++--
 9 files changed, 116 insertions(+), 35 deletions(-)
---
base-commit: bd703c23ae1dea86795e99d510fb9196566baa01
change-id: 20261118-superm1-amdgpu-memory-leak-f22abeab3189

Best regards,
--  
Mario Limonciello <mario.limonciello@amd.com>


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

end of thread, other threads:[~2026-11-18 19:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 19:02 [PATCH v2 0/3] fix TTM device_list use-after-free on failed probe Mario Limonciello
2026-11-18 19:02 ` [PATCH v2 1/3] drm/amdgpu: unwind TTM on amdgpu_ttm_init() failure Mario Limonciello
2026-11-18 19:03 ` [PATCH v2 2/3] drm/amdgpu: unwind bo_init on GMC sw_init failure Mario Limonciello
2026-11-18 19:03 ` [PATCH v2 3/3] drm/amdgpu: release WC memtype and MTRR when amdgpu_bo_init() fails Mario Limonciello
2026-11-18 19:09   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox