drm/amdgpu: fix error handling in amdgpu_copy_buffer

drm_sched_job_add_resv_dependencies can fail in amdgpu_ttm_prepare_job.
In this case we need to use amdgpu_job_free to release memory.

---
v4: moved job pointer clearing to a different patchset
---

Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2025-11-24 18:25:04 +01:00 committed by Alex Deucher
parent 582c65e854
commit bc0515ece3

View file

@ -2393,7 +2393,7 @@ int amdgpu_copy_buffer(struct amdgpu_device *adev, uint64_t src_offset,
resv, vm_needs_flush, &job, false,
AMDGPU_KERNEL_JOB_ID_TTM_COPY_BUFFER);
if (r)
return r;
goto error_free;
for (i = 0; i < num_loops; i++) {
uint32_t cur_size_in_bytes = min(byte_count, max_bytes);
@ -2405,11 +2405,9 @@ int amdgpu_copy_buffer(struct amdgpu_device *adev, uint64_t src_offset,
byte_count -= cur_size_in_bytes;
}
if (r)
goto error_free;
*fence = amdgpu_ttm_job_submit(adev, job, num_dw);
return r;
return 0;
error_free:
amdgpu_job_free(job);