From: Ethan Tidmore <ethantidmore06@gmail.com>
To: Alex Deucher <alexander.deucher@amd.com>,
Christian König <christian.koenig@amd.com>,
amd-gfx@lists.freedesktop.org
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Lijo Lazar <lijo.lazar@amd.com>,
Mario Limonciello <superm1@kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>,
Ce Sun <cesun102@amd.com>, Yo-Jung Leo Lin <Leo.Lin@amd.com>,
Jammy Zhou <Jammy.Zhou@amd.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Ethan Tidmore <ethantidmore06@gmail.com>
Subject: [PATCH] drm/amdgpu: Fix resource leaks
Date: Tue, 24 Feb 2026 19:44:25 -0600 [thread overview]
Message-ID: <20260225014425.2474802-1-ethantidmore06@gmail.com> (raw)
There are multiple resource leaks due to ioremap() being used and
iounmap never being called in multiple possible error paths.
Change ioremap() to devm_ioremap() to fix all resource leaks at
once.
Detected by Smatch:
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:4834 amdgpu_device_init() warn:
'adev->rmmio' from ioremap() not released on lines:
4539,4549,4563,4574,4592,4834.
Fixes: d38ceaf99ed01 ("drm/amdgpu: add core driver (v4)")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 0acddcb04730..5cb58bed64ec 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4520,7 +4520,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
for (i = 0; i < AMD_IP_BLOCK_TYPE_NUM; i++)
atomic_set(&adev->pm.pwr_state[i], POWER_STATE_UNKNOWN);
- adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size);
+ adev->rmmio = devm_ioremap(adev->dev, adev->rmmio_base, adev->rmmio_size);
if (!adev->rmmio)
return -ENOMEM;
@@ -4843,8 +4843,6 @@ static void amdgpu_device_unmap_mmio(struct amdgpu_device *adev)
/* Unmap all mapped bars - Doorbell, registers and VRAM */
amdgpu_doorbell_fini(adev);
- iounmap(adev->rmmio);
- adev->rmmio = NULL;
if (adev->mman.aper_base_kaddr)
iounmap(adev->mman.aper_base_kaddr);
adev->mman.aper_base_kaddr = NULL;
@@ -4970,13 +4968,6 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
vga_client_unregister(adev->pdev);
- if (drm_dev_enter(adev_to_drm(adev), &idx)) {
-
- iounmap(adev->rmmio);
- adev->rmmio = NULL;
- drm_dev_exit(idx);
- }
-
if (IS_ENABLED(CONFIG_PERF_EVENTS))
amdgpu_pmu_fini(adev);
if (adev->discovery.bin)
--
2.53.0
next reply other threads:[~2026-02-25 8:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 1:44 Ethan Tidmore [this message]
2026-02-25 6:36 ` [PATCH] drm/amdgpu: Fix resource leaks kernel test robot
2026-02-27 4:17 ` Claude review: " Claude Code Review Bot
2026-02-27 4:17 ` Claude Code Review Bot
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=20260225014425.2474802-1-ethantidmore06@gmail.com \
--to=ethantidmore06@gmail.com \
--cc=Jammy.Zhou@amd.com \
--cc=Leo.Lin@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=cesun102@amd.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=lijo.lazar@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=simona@ffwll.ch \
--cc=superm1@kernel.org \
/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