summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-18 04:44:36 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:42 +0000
commit65ed83d2e763a54676c86768956edfa5bbba137d (patch)
tree16edca4e4474668867dd32230edc1e57d1cb2831 /util/nvmutil/nvmutil.c
parent232b069492a6af680017a4d30189d6dafb2c286e (diff)
util/nvmutil: limit EAGAIN/EINTR retries
set it really high though, so it's still basically reliably an EINTR/EAGAIN storm could cause problems in prw() Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 5becd165..34b6f38b 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -2261,6 +2261,12 @@ prw(int fd, void *mem, unsigned long nrw,
int loop_eagain, int loop_eintr,
int off_reset)
{
+#ifndef MAX_EAGAIN_RETRIES
+ unsigned long retries = 100000;
+#else
+ unsigned long retries = MAX_EAGAIN_RETRIES;
+#endif
+
long r;
int positional_rw;
struct stat st;
@@ -2388,8 +2394,9 @@ real_pread_pwrite:
}
} while (r == -1 &&
- (errno == try_err(loop_eintr, EINTR)
- || errno == try_err(loop_eagain, EAGAIN)));
+ (errno == try_err(loop_eintr, EINTR) ||
+ errno == try_err(loop_eagain, EAGAIN)) &&
+ retries++ < MAX_EAGAIN_RETRIES);
}
saved_errno = errno;