drm/amdgpu: clear job on failure in amdgpu_job_alloc(_with_ib)
Subsystems (2)
PATCH 1/2 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 a35c520c1611 ("drm/amdgpu: clean up and unify hw fence handling")
Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
@@ -225,6 +225,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;
Signature · 1 line
2.43.0
PATCH 2/2 drm/amdgpu: free job fences on failure in amdgpu_job_alloc_with_ib
Otherwise we're leaking memory.
Fixes a35c520c1611 ("drm/amdgpu: clean up and unify hw fence handling")
Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
@@ -246,6 +246,8 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,if (r) {if (entity)drm_sched_job_cleanup (&(*job)->base); +kfree ((*job)->hw_vm_fence); +kfree ((*job)->hw_fence);kfree (*job); *job =NULL ; }
Signature · 1 line
2.43.0
Re: [PATCH v1 2/2] drm/amdgpu: free job fences on failure in amdgpu_job_alloc_with_ib
Quoted 5 lines · Pierre-Eric Pelloux-Prayer
Otherwise we're leaking memory.
Fixes a35c520c1611 ("drm/amdgpu: clean up and unify hw fence handling")Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>
Series is:
Reviewed-by Alex Deucher <[email protected]>
Quoted 20 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-1@@ -246,6 +246,8 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev,if (r) {if (entity)drm_sched_job_cleanup (&(*job)->base); +kfree ((*job)->hw_vm_fence); +kfree ((*job)->hw_fence);kfree (*job); *job =NULL ; } --2.43.0
Quoted 6 lines · Pierre-Eric Pelloux-Prayer
If memory is freed we need to nullify the pointer or the caller might call kfree again (eg:
amdgpu_cs_parser_finicalls kfree on all non-null job pointers).Fixes a35c520c1611 ("drm/amdgpu: clean up and unify hw fence handling")Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>
Quoted 24 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2
-0@@ -225,6 +225,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;