[PATCH v2 16/23] plugins/amdgpu: Check sdma operation type early and once
Tvrtko Ursulin <[email protected]> Fri, 10 Apr 2026 19:55:07 +0100
| Newsgroups | dev.linux.lists.criu |
|---|---|
| Message-ID | <[email protected]> |
Check SDMA operation type once at the beginning of the copy helper and fix one incorrect usage of pr_perror while at it. Signed-off-by: Tvrtko Ursulin <[email protected]> Reviewed-By: David Francis <[email protected]> --- plugins/amdgpu/amdgpu_plugin.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c index f2d1bcf44cab..9aa9b3fb514c 100644 --- a/plugins/amdgpu/amdgpu_plugin.c +++ b/plugins/amdgpu/amdgpu_plugin.c @@ -559,6 +559,11 @@ int sdma_copy_bo(int shared_fd, uint64_t size, FILE *storage_fp, uint32_t *ib = NULL; int j, err, err2, packets_per_buffer; + if (type != SDMA_OP_VRAM_READ && type != SDMA_OP_VRAM_WRITE) { + pr_err("Invalid sdma operation"); + return -EINVAL; + } + buffer_bo_size = min(size, buffer_size); packets_per_buffer = ((buffer_bo_size - 1) / max_copy_size) + 1; src_bo_size = (type == SDMA_OP_VRAM_WRITE) ? buffer_bo_size : size; @@ -581,9 +586,6 @@ int sdma_copy_bo(int shared_fd, uint64_t size, FILE *storage_fp, } h_bo_src = res.buf_handle; break; - default: - pr_perror("Invalid sdma operation"); - return -EINVAL; } err = amdgpu_va_range_alloc(h_dev, amdgpu_gpu_va_range_general, src_bo_size, 0x1000, 0, &gpu_addr_src, @@ -616,9 +618,6 @@ int sdma_copy_bo(int shared_fd, uint64_t size, FILE *storage_fp, goto err_dst_bo_prep; } break; - default: - pr_perror("Invalid sdma operation"); - goto err_dst_bo_prep; } err = amdgpu_va_range_alloc(h_dev, amdgpu_gpu_va_range_general, dst_bo_size, 0x1000, 0, &gpu_addr_dst, -- 2.52.0