mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
drm/amd/amdgpu: Fix potential ioremap() memory leaks in amdgpu_device_init()
[ Upstream commit eb4f139888f636614dab3bcce97ff61cefc4b3a7 ] This ensures that the memory mapped by ioremap for adev->rmmio, is properly handled in amdgpu_device_init(). If the function exits early due to an error, the memory is unmapped. If the function completes successfully, the memory remains mapped. Reported by smatch: 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 Cc: Christian König <christian.koenig@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
354a5d7bb7
commit
3a94feab04
@@ -3713,8 +3713,10 @@ int amdgpu_device_init(struct amdgpu_device *adev,
|
|||||||
* early on during init and before calling to RREG32.
|
* early on during init and before calling to RREG32.
|
||||||
*/
|
*/
|
||||||
adev->reset_domain = amdgpu_reset_create_reset_domain(SINGLE_DEVICE, "amdgpu-reset-dev");
|
adev->reset_domain = amdgpu_reset_create_reset_domain(SINGLE_DEVICE, "amdgpu-reset-dev");
|
||||||
if (!adev->reset_domain)
|
if (!adev->reset_domain) {
|
||||||
return -ENOMEM;
|
r = -ENOMEM;
|
||||||
|
goto unmap_memory;
|
||||||
|
}
|
||||||
|
|
||||||
/* detect hw virtualization here */
|
/* detect hw virtualization here */
|
||||||
amdgpu_detect_virtualization(adev);
|
amdgpu_detect_virtualization(adev);
|
||||||
@@ -3722,18 +3724,18 @@ int amdgpu_device_init(struct amdgpu_device *adev,
|
|||||||
r = amdgpu_device_get_job_timeout_settings(adev);
|
r = amdgpu_device_get_job_timeout_settings(adev);
|
||||||
if (r) {
|
if (r) {
|
||||||
dev_err(adev->dev, "invalid lockup_timeout parameter syntax\n");
|
dev_err(adev->dev, "invalid lockup_timeout parameter syntax\n");
|
||||||
return r;
|
goto unmap_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* early init functions */
|
/* early init functions */
|
||||||
r = amdgpu_device_ip_early_init(adev);
|
r = amdgpu_device_ip_early_init(adev);
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
goto unmap_memory;
|
||||||
|
|
||||||
/* Get rid of things like offb */
|
/* Get rid of things like offb */
|
||||||
r = drm_aperture_remove_conflicting_pci_framebuffers(adev->pdev, &amdgpu_kms_driver);
|
r = drm_aperture_remove_conflicting_pci_framebuffers(adev->pdev, &amdgpu_kms_driver);
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
goto unmap_memory;
|
||||||
|
|
||||||
/* Enable TMZ based on IP_VERSION */
|
/* Enable TMZ based on IP_VERSION */
|
||||||
amdgpu_gmc_tmz_set(adev);
|
amdgpu_gmc_tmz_set(adev);
|
||||||
@@ -3743,7 +3745,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
|
|||||||
if (adev->gmc.xgmi.supported) {
|
if (adev->gmc.xgmi.supported) {
|
||||||
r = adev->gfxhub.funcs->get_xgmi_info(adev);
|
r = adev->gfxhub.funcs->get_xgmi_info(adev);
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
goto unmap_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable PCIE atomic ops */
|
/* enable PCIE atomic ops */
|
||||||
@@ -3999,6 +4001,8 @@ release_ras_con:
|
|||||||
failed:
|
failed:
|
||||||
amdgpu_vf_error_trans_all(adev);
|
amdgpu_vf_error_trans_all(adev);
|
||||||
|
|
||||||
|
unmap_memory:
|
||||||
|
iounmap(adev->rmmio);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user