diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-09 21:02:33 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-09 21:06:18 +0000 |
| commit | f8ddb6ef8439a2f5c185ab96dcb412b8dfb04cbb (patch) | |
| tree | 56d0fea005a43adac42ecc32a40db7afc6caeab6 /util/nvmutil/nvmutil.c | |
| parent | c59b3b7638c53382c22e12b25888836f9553c8ab (diff) | |
util/nvmutil: fix EINTR detection on urandom read
i forgot to handle it in the previous refactor
not really a problem in practise, since the first
read probably succeeds anyway.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 3bae308f..8a2d6ef0 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -992,10 +992,17 @@ read_dev_urandom(int fd, void *buf, size_t len) for (retry = 0; retry < MAX_RETRY_RW; retry++) { rval = read(fd, buf, len); - if (rval && (size_t)rval <= len) { - errno = 0; - return rval; + if (rval == -1) { + if (errno == EINTR) + continue; + err(errno, "%s", rname); } + + if (!rval || (size_t)rval > len) + continue; + + errno = 0; + return rval; } err(EINTR, "%s: read: max retries exceeded: %s", rname); @@ -1228,7 +1235,7 @@ write_gbe_file_part(size_t p) if (rval != -1) err(ECANCELED, - "%s: Short pwrite, %zd bytes", + "%s: Short pwrite of %zd bytes", fname, rval); if (errno != EINTR) |
