summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-13 14:41:36 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-13 14:41:36 +0000
commit2d129c257ccba03229048131a8617e216ecdebdb (patch)
tree79e5b0516319dd1eca0a952d95963a17ed906156 /util/nvmutil
parent087c7a6ad2e49f25c1dfddc7e2cf5bd23f4c8f95 (diff)
util/nvmutil: tidy up prw()
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index b659f254..667726ab 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -1663,20 +1663,22 @@ prw(int fd, void *mem, size_t nrw,
|| (unsigned int)prw_type > IO_WRITE)
goto err_prw;
+ flags = fcntl(fd, F_GETFL);
+ if (flags == -1)
+ return -1;
+
/*
* O_APPEND must not be used, because this
* allows POSIX write() to ignore the
* current write offset and write at EOF,
* which would therefore break pread/pwrite
*/
- flags = fcntl(fd, F_GETFL);
- if (flags == -1)
- return -1;
if (flags & O_APPEND)
goto err_prw;
if ((off_orig = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
return -1;
+
if (lseek_eintr(fd, off, SEEK_SET) == (off_t)-1)
return -1;
@@ -1688,6 +1690,7 @@ prw(int fd, void *mem, size_t nrw,
if (lseek_eintr(fd, off_orig, SEEK_SET) == (off_t)-1) {
if (r < 0)
errno = saved_errno;
+
return -1;
}
errno = saved_errno;