]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: free hw_vm_fence when fail in amdgpu_job_alloc
authorJiqian Chen <Jiqian.Chen@amd.com>
Wed, 14 Jan 2026 10:06:10 +0000 (18:06 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 20 Jan 2026 22:16:37 +0000 (17:16 -0500)
If drm_sched_job_init fails, hw_vm_fence is not freed currently,
then cause memory leak.

Fixes: db36632ea51e ("drm/amdgpu: clean up and unify hw fence handling")
Link: https://lore.kernel.org/amd-gfx/a5a828cb-0e4a-41f0-94c3-df31e5ddad52@amd.com/T/#t
Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
Reviewed-by: Amos Kong <kongjianjun@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c

index c533c080691236e6038eaa6ab5ab4677572f3f7b..aaf5477fcd7ac6a0eb08174fbb9a906c8e56967b 100644 (file)
@@ -218,8 +218,11 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,
        if (!entity)
                return 0;
 
-       return drm_sched_job_init(&(*job)->base, entity, 1, owner,
-                                 drm_client_id);
+       r = drm_sched_job_init(&(*job)->base, entity, 1, owner, drm_client_id);
+       if (!r)
+               return 0;
+
+       kfree((*job)->hw_vm_fence);
 
 err_fence:
        kfree((*job)->hw_fence);