[PATCH 12/25] plugins/amdgpu: Add error handling for seek operations
Tvrtko Ursulin <[email protected]> Wed, 11 Mar 2026 09:59:01 +0000
| Newsgroups | dev.linux.lists.criu |
|---|---|
| Message-ID | <[email protected]> |
Extra safety so the calls do not stick out as the only ones with no error checking. Signed-off-by: Tvrtko Ursulin <[email protected]> Reviewed-By: David Francis <[email protected]> --- plugins/amdgpu/amdgpu_plugin.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c index 3d59eb23bcb3..cfa6fda230f3 100644 --- a/plugins/amdgpu/amdgpu_plugin.c +++ b/plugins/amdgpu/amdgpu_plugin.c @@ -2298,6 +2298,11 @@ void *parallel_restore_bo_contents(void *_thread_data) goto err_sdma; } offset = ftell(bo_contents_fp); + if (offset < 0) { + ret = -errno; + pr_perror("Failed to alloc aligned memory. Consider setting KFD_MAX_BUFFER_SIZE."); + goto err_sdma; + } posix_memalign(&buffer, sysconf(_SC_PAGE_SIZE), buffer_size); if (!buffer) { @@ -2311,7 +2316,13 @@ void *parallel_restore_bo_contents(void *_thread_data) continue; entry = &restore_cmd->entries[i]; - fseeko(bo_contents_fp, entry->read_offset + offset, SEEK_SET); + ret = fseeko(bo_contents_fp, entry->read_offset + offset, + SEEK_SET); + if (ret < 0) { + ret = -errno; + pr_err("Failed to seek for BO using sDMA: bo_buckets[%d]\n", i); + goto err_sdma; + } ret = sdma_copy_bo(restore_cmd->fds_write[entry->write_id], entry->size, bo_contents_fp, buffer, buffer_size, h_dev, max_copy_size, SDMA_OP_VRAM_WRITE, false); -- 2.52.0