提交 9f5b8c1b 编写于 作者: J Jiri Kosina 提交者: Zheng Zengkai

drm/amdgpu: Fix resource leak on probe error path

stable inclusion
from stable-5.10.56
commit fc2756cce06f9833ebabd309b5b5080ed5c56897
bugzilla: 176004 https://gitee.com/openeuler/kernel/issues/I4DYZ4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=fc2756cce06f9833ebabd309b5b5080ed5c56897

--------------------------------

commit d47255d3 upstream.

This reverts commit 4192f7b5.

It is not true (as stated in the reverted commit changelog) that we never
unmap the BAR on failure; it actually does happen properly on
amdgpu_driver_load_kms() -> amdgpu_driver_unload_kms() ->
amdgpu_device_fini() error path.

What's worse, this commit actually completely breaks resource freeing on
probe failure (like e.g. failure to load microcode), as
amdgpu_driver_unload_kms() notices adev->rmmio being NULL and bails too
early, leaving all the resources that'd normally be freed in
amdgpu_acpi_fini() and amdgpu_device_fini() still hanging around, leading
to all sorts of oopses when someone tries to, for example, access the
sysfs and procfs resources which are still around while the driver is
gone.

Fixes: 4192f7b5 ("drm/amdgpu: unmap register bar on device init failure")
Reported-by: NVojtech Pavlik <vojtech@ucw.cz>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 624895f5
...@@ -3322,13 +3322,13 @@ int amdgpu_device_init(struct amdgpu_device *adev, ...@@ -3322,13 +3322,13 @@ 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");
goto failed_unmap; return r;
} }
/* early init functions */ /* early init functions */
r = amdgpu_device_ip_early_init(adev); r = amdgpu_device_ip_early_init(adev);
if (r) if (r)
goto failed_unmap; return r;
/* doorbell bar mapping and doorbell index init*/ /* doorbell bar mapping and doorbell index init*/
amdgpu_device_doorbell_init(adev); amdgpu_device_doorbell_init(adev);
...@@ -3532,10 +3532,6 @@ int amdgpu_device_init(struct amdgpu_device *adev, ...@@ -3532,10 +3532,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
if (boco) if (boco)
vga_switcheroo_fini_domain_pm_ops(adev->dev); vga_switcheroo_fini_domain_pm_ops(adev->dev);
failed_unmap:
iounmap(adev->rmmio);
adev->rmmio = NULL;
return r; return r;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册