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

Jinjie Ruan ruanjinjie at huawei.com
Fri Sep 6 02:02:33 UTC 2024


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 at huawei.com>
Suggested-by: Thomas Gleixner <tglx at linutronix.de>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

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();
-- 
2.34.1



More information about the dri-devel mailing list