summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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.
*/