From 736a2504bbe1014fc2804c311e10b72826a71b74 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 1 Apr 2026 17:43:43 +0100 Subject: lbutils/file: don't loop EINTR on close() state is undefined after EINTR. just abort universally. Signed-off-by: Leah Rowe --- util/libreboot-utils/lib/file.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'util/libreboot-utils/lib/file.c') diff --git a/util/libreboot-utils/lib/file.c b/util/libreboot-utils/lib/file.c index 9af3b89e..862e82cc 100644 --- a/util/libreboot-utils/lib/file.c +++ b/util/libreboot-utils/lib/file.c @@ -110,7 +110,7 @@ fsync_dir(const char *path) if_err_sys((rval = fsync_on_eintr(dirfd)) == -1)) goto err_fsync_dir; - close_on_eintr(&dirfd); + xclose(&dirfd); free_and_set_null(&dirbuf); reset_caller_errno(rval); @@ -118,7 +118,7 @@ fsync_dir(const char *path) err_fsync_dir: free_and_set_null(&dirbuf); - close_on_eintr(&dirfd); + xclose(&dirfd); return with_fallback_errno(EIO); } @@ -419,7 +419,7 @@ fs_resolve_at(int dirfd, const char *path, int flags) /* close previous fd if not the original input */ if (curfd != dirfd) - close_on_eintr(&curfd); + xclose(&curfd); curfd = nextfd; nextfd = -1; @@ -432,11 +432,11 @@ err: saved_errno = errno; if (nextfd >= 0) - close_on_eintr(&nextfd); + xclose(&nextfd); /* close curfd only if it's not the original */ if (curfd != dirfd && curfd >= 0) - close_on_eintr(&curfd); + xclose(&curfd); errno = saved_errno; return with_fallback_errno(EIO); @@ -721,22 +721,19 @@ fsync_on_eintr(int fd) } void -close_on_eintr(int *fd) +xclose(int *fd) { int saved_errno = errno; int rval = 0; if (fd == NULL) - exitf("close_on_eintr: null pointer"); + exitf("xclose: null pointer"); if (*fd < 0) return; errno = 0; - while (fs_retry(saved_errno, - rval = close(*fd))); - - if (rval < 0) - exitf("close_on_eintr: could not close"); + if ((rval = close(*fd)) < 0) + exitf("xclose: could not close"); *fd = -1; -- cgit v1.2.1