Skip to contentSkip to conversation

drm/amdgpu: Fix leak when GPU memory allocation fails

PATCH In review Mukul Joshi 2 participants 2 messages Apr 18, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix leak when GPU memory allocation fails

Free the sync object if the memory allocation fails for any reason.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -0
index 0ae9fd844623..bcf4a9e82075 100644
@@ -1854,6 +1854,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
 err_bo_create:
 	amdgpu_amdkfd_unreserve_mem_limit(adev, aligned_size, flags, xcp_id);
 err_reserve_limit:
+	amdgpu_sync_free(&(*mem)->sync);
 	mutex_destroy(&(*mem)->lock);
 	if (gobj)
 		drm_gem_object_put(gobj);
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

[Public]

________________________________
From: amd-gfx <[email protected]> on behalf of Mukul Joshi <[email protected]>
Sent: Thursday, April 18, 2024 12:17 PM
To: [email protected] <[email protected]>
Cc: Kuehling, Felix <[email protected]>; Joshi, Mukul <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix leak when GPU memory allocation fails

Free the sync object if the memory allocation fails for any reason.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -0
index 0ae9fd844623..bcf4a9e82075 100644
@@ -1854,6 +1854,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
 err_bo_create:
         amdgpu_amdkfd_unreserve_mem_limit(adev, aligned_size, flags, xcp_id);
 err_reserve_limit:
+       amdgpu_sync_free(&(*mem)->sync);
         mutex_destroy(&(*mem)->lock);
         if (gobj)
                 drm_gem_object_put(gobj);

--
2.35.1