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