From 890d1a2ff603a1717498ba3d6a74f1c0f27c2415 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 10 Mar 2026 10:18:25 +0000 Subject: util/nvmutil: err if file offset fails currently it returns success, if restoring a previous offset failed. this leaves descriptor corrupted when the caller thinks otherwise return -1 instead, so that the caller can treat it as an error, relying on whatever lseek had set for errno Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index f6174352..ac94e690 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1370,13 +1370,13 @@ static ssize_t prw(int fd, void *mem, size_t count, off_t offset, int rw_type, const char *path) { - off_t rs; off_t old; ssize_t r; if ((old = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1) return -1; - if ((r = lseek_eintr(fd, offset, SEEK_SET)) == (off_t)-1) + + if (lseek_eintr(fd, offset, SEEK_SET) == (off_t)-1) return -1; do { @@ -1389,8 +1389,8 @@ prw(int fd, void *mem, size_t count, } while (r < 0 && errno == EINTR); if (r >= 0) { - if ((rs = lseek_eintr(fd, old, SEEK_SET)) == (off_t)-1) - errno = EIO; + if (lseek_eintr(fd, old, SEEK_SET) == (off_t)-1) + return -1; } return r; -- cgit v1.2.1