drm/amdgpu: Fix leak when GPU memory allocation fails
authorMukul Joshi <mukul.joshi@amd.com>
Thu, 18 Apr 2024 15:32:34 +0000 (11:32 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 19 Apr 2024 03:54:49 +0000 (23:54 -0400)
Free the sync object if the memory allocation fails for any
reason.

Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

index df58a6a..7c23ba1 100644 (file)
@@ -1854,6 +1854,7 @@ err_node_allow:
 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);