From c1c1aee6955fe94b1a3f1d8b2b9e065f26ab5fdf Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 23 Mar 2026 08:21:18 +0000 Subject: mkhtemp: fix initialisied fd Signed-off-by: Leah Rowe --- util/nvmutil/lib/file.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'util/nvmutil') 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. */ -- cgit v1.2.1