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 <David.Francis@amd.com>
This commit is contained in:
David Francis 2026-03-13 10:11:31 -04:00 committed by Andrei Vagin
parent af3f4be066
commit bd4cd4e9ee
2 changed files with 10 additions and 0 deletions

View file

@ -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);

View file

@ -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);