Skip to content

Commit d036cd5

Browse files
committed
libebgenv: Only release CONFIG_PART::mountpoint early on errors
This fixes a regression caused by premature cleanup: If probe_config_file() ran successfully and found an already mounted partition, its mountpoint must not be released yet. bgenv_finalize() will take care of that. However, if probe_config_file() failed, it must free any previously created mountpoint string prior to returning. That is what c2be7c1 was actually trying to resolve. Reported-by: Ingo Rah <ingo.rah@linutronix.de> Fixes: c2be7c1 ("libebgenv: fix memory leak in partition probing") Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
1 parent c6fc548 commit d036cd5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

env/env_config_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ bool probe_config_file(CONFIG_PART *cfgpart)
8585
}
8686
if (do_unmount) {
8787
unmount_partition(cfgpart);
88-
} else {
88+
} else if (!result) {
8989
free(cfgpart->mountpoint);
9090
cfgpart->mountpoint = NULL;
9191
}

0 commit comments

Comments
 (0)