On 2026/1/14 18:52, Christian König wrote: > > > On 1/14/26 11:17, Jiqian Chen wrote: >> If drm_sched_job_init fails, hw_vm_fence is not freed currently, >> then cause memory leak. >> >> Signed-off-by: Jiqian Chen <[email protected]> >> --- >> drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c >> index 7f5d01164897..a5d3b35353da 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c >> @@ -216,11 +216,11 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, >> struct amdgpu_vm *vm, >> (*job)->generation = amdgpu_vm_generation(adev, vm); >> (*job)->vm_pd_addr = AMDGPU_BO_INVALID_OFFSET; >> >> - if (!entity) >> + if (!entity || >> + !drm_sched_job_init(&(*job)->base, entity, 1, owner, >> drm_client_id)) >> return 0; > > That is not even remotely correct. > > You need to assign the return code and check that instead, otherwise you > return success when a failure occurred and just crash. You're right, I've realized that too. Will change in next version.
> > Regards, > Christian. > >> >> - return drm_sched_job_init(&(*job)->base, entity, 1, owner, >> - drm_client_id); >> + kfree((*job)->hw_vm_fence); >> >> err_fence: >> kfree((*job)->hw_fence); > -- Best regards, Jiqian Chen.
