From 199f71f620fed718287dc89d588da0cda8d6588f Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Sat, 14 Mar 2026 17:00:28 +0000 Subject: [PATCH] plugin/amdgpu: set errno in open_img_file() on read/write failure open_img_file() can return NULL after a read_fp() or write_fp() failure without setting errno. The openat() and fdopen() paths set errno, but the read/write path does not, so callers using -errno get zero or a stale value. Set errno to EIO on this path so errno is always valid when the function returns NULL. Signed-off-by: Radostin Stoyanov --- plugins/amdgpu/amdgpu_plugin_util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/amdgpu/amdgpu_plugin_util.c b/plugins/amdgpu/amdgpu_plugin_util.c index 12d61dcb6..7fef4dadf 100644 --- a/plugins/amdgpu/amdgpu_plugin_util.c +++ b/plugins/amdgpu/amdgpu_plugin_util.c @@ -262,6 +262,7 @@ FILE *open_img_file(char *path, bool write, size_t *size, bool expect_present) if (ret) { pr_err("%s:Failed to access file size\n", path); fclose(fp); + errno = EIO; return NULL; }