1 From e8288ef80c0ad498e190ee529884317787e5b701 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Fri, 23 Feb 2024 17:08:16 +0530
4 Subject: drm/amd/amdgpu: Fix potential ioremap() memory leaks in
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 From: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
12 [ Upstream commit eb4f139888f636614dab3bcce97ff61cefc4b3a7 ]
14 This ensures that the memory mapped by ioremap for adev->rmmio, is
15 properly handled in amdgpu_device_init(). If the function exits early
16 due to an error, the memory is unmapped. If the function completes
17 successfully, the memory remains mapped.
20 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:4337 amdgpu_device_init() warn: 'adev->rmmio' from ioremap() not released on lines: 4035,4045,4051,4058,4068,4337
22 Cc: Christian König <christian.koenig@amd.com>
23 Cc: Alex Deucher <alexander.deucher@amd.com>
24 Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
25 Reviewed-by: Christian König <christian.koenig@amd.com>
26 Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
27 Signed-off-by: Sasha Levin <sashal@kernel.org>
29 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 ++++++++++------
30 1 file changed, 10 insertions(+), 6 deletions(-)
32 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
33 index d0afb9ba3789c..1eff446321bd6 100644
34 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
35 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
36 @@ -4025,8 +4025,10 @@ int amdgpu_device_init(struct amdgpu_device *adev,
37 * early on during init and before calling to RREG32.
39 adev->reset_domain = amdgpu_reset_create_reset_domain(SINGLE_DEVICE, "amdgpu-reset-dev");
40 - if (!adev->reset_domain)
42 + if (!adev->reset_domain) {
47 /* detect hw virtualization here */
48 amdgpu_detect_virtualization(adev);
49 @@ -4036,20 +4038,20 @@ int amdgpu_device_init(struct amdgpu_device *adev,
50 r = amdgpu_device_get_job_timeout_settings(adev);
52 dev_err(adev->dev, "invalid lockup_timeout parameter syntax\n");
57 /* early init functions */
58 r = amdgpu_device_ip_early_init(adev);
63 amdgpu_device_set_mcbp(adev);
65 /* Get rid of things like offb */
66 r = drm_aperture_remove_conflicting_pci_framebuffers(adev->pdev, &amdgpu_kms_driver);
71 /* Enable TMZ based on IP_VERSION */
72 amdgpu_gmc_tmz_set(adev);
73 @@ -4059,7 +4061,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
74 if (adev->gmc.xgmi.supported) {
75 r = adev->gfxhub.funcs->get_xgmi_info(adev);
81 /* enable PCIE atomic ops */
82 @@ -4328,6 +4330,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
84 amdgpu_vf_error_trans_all(adev);
87 + iounmap(adev->rmmio);