From bd4cd4e9eebdb0c5bb62b566f2dee0ee9d11e875 Mon Sep 17 00:00:00 2001 From: David Francis Date: Fri, 13 Mar 2026 10:11:31 -0400 Subject: [PATCH] plugin/amdgpu: Check output of open_img_file open_img_file can return null if, for example, the dump file isn't present. Tehre were three places where this wasn't checked. Check it. Signed-off-by: David Francis --- plugins/amdgpu/amdgpu_plugin.c | 6 ++++++ plugins/amdgpu/amdgpu_plugin_drm.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/plugins/amdgpu/amdgpu_plugin.c b/plugins/amdgpu/amdgpu_plugin.c index 8d14f1a8b..42eeaf7e0 100644 --- a/plugins/amdgpu/amdgpu_plugin.c +++ b/plugins/amdgpu/amdgpu_plugin.c @@ -1141,6 +1141,9 @@ int amdgpu_restore_init(void) while ((dir = readdir(d)) != NULL) { if (strncmp("amdgpu-kfd-", dir->d_name, strlen("amdgpu-kfd-")) == 0) { img_fp = open_img_file(dir->d_name, false, &img_size); + if (!img_fp) + return -EINVAL; + buf = xmalloc(img_size); if (!buf) { fclose(img_fp); @@ -1163,6 +1166,9 @@ int amdgpu_restore_init(void) } if (strncmp("amdgpu-renderD-", dir->d_name, strlen("amdgpu-renderD-")) == 0) { img_fp = open_img_file(dir->d_name, false, &img_size); + if (!img_fp) + return -EINVAL; + buf = xmalloc(img_size); if (!buf) { fclose(img_fp); diff --git a/plugins/amdgpu/amdgpu_plugin_drm.c b/plugins/amdgpu/amdgpu_plugin_drm.c index 3520bca7a..dedce9e46 100644 --- a/plugins/amdgpu/amdgpu_plugin_drm.c +++ b/plugins/amdgpu/amdgpu_plugin_drm.c @@ -210,6 +210,10 @@ static int restore_bo_contents_drm(int drm_render_minor, CriuRenderNode *rd, int snprintf(img_path, sizeof(img_path), IMG_DRM_PAGES_FILE, rd->id, drm_render_minor, i); bo_contents_fp = open_img_file(img_path, false, &image_size); + if (!bo_contents_fp) { + ret = -EINVAL; + break; + } ret = sdma_copy_bo(dmabufs[i], rd->bo_entries[i]->size, bo_contents_fp, buffer, buffer_size, h_dev, max_copy_size, SDMA_OP_VRAM_WRITE, true);