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-18 00:29:33 +0000
commit6262826627a00739c501c020c5f017b319651484 (patch)
treedf9990feed73f710b0e4a223ddc1fe7621c9ba67 /util/nvmutil
parent2723a9ccd8e2167b1c5547a1cf8cd6d651613d28 (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