summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-08 20:50:44 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-08 20:50:44 +0000
commit840f79fd82839b6031c67f22e955aa87395ffb45 (patch)
tree570ac438148a99940fd2092d4a511e6dcc66c38e /util/nvmutil/nvmutil.c
parent1400508400064798eb28d4c18e70e929bc18e748 (diff)
util/nvmutil: only close gbe fd if opened
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index d7cd943c..7cc782c8 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -372,8 +372,10 @@ main(int argc, char *argv[])
else if (gbe_flags != O_RDONLY)
write_gbe_file();
- if (close(gbe_fd) == -1)
- err(ECANCELED, "close '%s'", fname);
+ if (gbe_fd > -1) {
+ if (close(gbe_fd) == -1)
+ err(ECANCELED, "close '%s'", fname);
+ }
#ifndef HAVE_ARC4RANDOM_BUF
if (urandom_fd > -1) {
@@ -694,6 +696,11 @@ read_gbe_file_part(size_t p)
GBE_PART_SIZE, gbe_file_offset(p, "pread"), fname, "pread");
}
+/*
+ * This is the first defense, but individual
+ * commands should still perform checksum
+ * verification where indicated, as a fallback.
+ */
static void
read_checksums(void)
{