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 <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov 2026-03-14 17:00:28 +00:00 committed by Alexander Mikhalitsyn
parent 0377c41261
commit 199f71f620
No known key found for this signature in database
GPG key ID: B1F47F5CB05B4FA3

View file

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