summaryrefslogtreecommitdiff
path: root/util/nvmutil/lib/file.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-23 08:21:18 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-23 08:21:18 +0000
commitc1c1aee6955fe94b1a3f1d8b2b9e065f26ab5fdf (patch)
tree5ae1732a27fc44f1c089548e220458ea9030ec72 /util/nvmutil/lib/file.c
parentf18f995c42b22799a705eb2718fc137e008fbb36 (diff)
mkhtemp: fix initialisied fd
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/lib/file.c')
-rw-r--r--util/nvmutil/lib/file.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/util/nvmutil/lib/file.c b/util/nvmutil/lib/file.c
index f9a1ba8a..e8dfd865 100644
--- a/util/nvmutil/lib/file.c
+++ b/util/nvmutil/lib/file.c
@@ -968,8 +968,8 @@ mkhtemp_try_create(int dirfd,
goto err;
/* ^ NOTE: opening the directory here
- will never set errno=EEXIST,
- since we're not creating it */
+ will never set errno=EEXIST,
+ since we're not creating it */
dir_created = 1;
@@ -977,6 +977,11 @@ mkhtemp_try_create(int dirfd,
if (fd_verify_dir_identity(dirfd, st_dir_initial) < 0)
goto err;
+ *fd = openat2p(dirfd, fname_copy,
+ O_RDONLY | O_DIRECTORY | O_CLOEXEC, 0);
+ if (*fd < 0)
+ goto err;
+
if (fstat(*fd, &st_open) < 0)
goto err;
@@ -985,11 +990,6 @@ mkhtemp_try_create(int dirfd,
goto err;
}
- *fd = openat2p(dirfd, fname_copy,
- O_RDONLY | O_DIRECTORY | O_CLOEXEC, 0);
- if (*fd < 0)
- goto err;
-
/* NOTE: could check nlink count here,
* but it's not very reliable here. skipped.
*/