diff mbox series

drm/amdgpu: Fix incorrect resource realease in amdgpu_init()

Message ID 20240906020233.272405-1-ruanjinjie@huawei.com (mailing list archive)
State New, archived
Headers show
Series drm/amdgpu: Fix incorrect resource realease in amdgpu_init() | expand

Commit Message

Jinjie Ruan Sept. 6, 2024, 2:02 a.m. UTC
If pci_register_driver() fails, amdgpu_sync_slab and amdgpu_fence_slab
should be freed in the error path, fix it.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 094498a0964b..3e73306a883d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -3046,7 +3046,14 @@  static int __init amdgpu_init(void)
 	amdgpu_amdkfd_init();
 
 	/* let modprobe override vga console setting */
-	return pci_register_driver(&amdgpu_kms_pci_driver);
+	r = pci_register_driver(&amdgpu_kms_pci_driver);
+	if (r)
+		goto error_pci_register;
+
+	return 0;
+
+error_pci_register:
+	amdgpu_fence_slab_fini();
 
 error_fence:
 	amdgpu_sync_fini();