summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-18 00:29:33 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:42 +0000
commite087d2cf77854a44c79df9c653a2f96b96dcba27 (patch)
treec1a52783027b625520a8e26b071b31500fe6f022 /util/nvmutil
parent562dc9232585ec76abb5c45e528f61f4b0d7bb3b (diff)
nvmutil: even stronger double-run protection
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 4e4d75b3..33d20c9f 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -746,18 +746,18 @@ good_checksum(unsigned long partnum)
void
run_cmd(void)
{
- unsigned long cmd_num;
- struct commands *cmd;
+ unsigned long i = x->i;
+ void (*run)(void) = x->cmd[i].run;
- cmd_num = x->i;
- cmd = &x->cmd[cmd_num];
+ check_command_num(i);
- check_command_num(cmd_num);
+ if (run == NULL)
+ err(EINVAL, "Command %lu: null ptr", i);
- if (cmd->run == NULL)
- err(EINVAL, "Command %lu: null ptr", cmd_num);
+ run();
- cmd->run();
+ for (i = 0; i < items(x->cmd); i++)
+ x->cmd[i].run = cmd_helper_err;
}
void