From: Pierre-Eric Pelloux-Prayer Date: Mon, 24 Nov 2025 14:33:41 +0000 (+0100) Subject: drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib) X-Git-Url: https://gentwo.org/gitweb/?a=commitdiff_plain;h=723c1dd3629d2d6eb319247d4eaba9f7b78319fa;p=linux%2F.git drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib) 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 Reviewed-by: Alex Deucher Reviewed-by: Christian König Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index 7d8ef7ae10c2..0707d2c2326f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -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;