From: Pierre-Eric Pelloux-Prayer Date: Mon, 24 Nov 2025 17:25:04 +0000 (+0100) Subject: drm/amdgpu: fix error handling in amdgpu_copy_buffer X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc0515ece3d50ea61f76795bcdb42b09640c11e1;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Christian König Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 26f0dac049a51..dcf53a78a28ab 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -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);