]> Gentwo Git Trees - linux/.git/commitdiff
drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib)
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Mon, 24 Nov 2025 14:33:41 +0000 (15:33 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 26 Nov 2025 16:25:29 +0000 (11:25 -0500)
If memory is freed we need to nullify the pointer or the caller
might call kfree again (eg: amdgpu_cs_parser_fini calls kfree on
all non-null job pointers).

Fixes: db36632ea51e ("drm/amdgpu: clean up and unify hw fence handling")
Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.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 7d8ef7ae10c23a2dcfa9a3a50efc70ccba332d61..0707d2c2326f486e392cd6b9977d2f8c62bf40f1 100644 (file)
@@ -224,6 +224,7 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm,
        kfree((*job)->hw_fence);
 err_job:
        kfree(*job);
+       *job = NULL;
 
        return r;
 }
@@ -246,6 +247,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,
                if (entity)
                        drm_sched_job_cleanup(&(*job)->base);
                kfree(*job);
+               *job = NULL;
        }
 
        return r;